Beginner Java Programming: Difference between revisions

From TrcWiki
Jump to navigation Jump to search
No edit summary
No edit summary
 
Line 3: Line 3:
=== Class 1 ===
=== Class 1 ===
* Introduction, overview: Everyone should bring a laptop to class. Student laptops are ok.
* Introduction, overview: Everyone should bring a laptop to class. Student laptops are ok.
* Set up replit.com accounts: Most students use their google account to sign in.
* Set up [replit.com](https://replit.com/signup) accounts: Most students use their google account to sign in.
* Create first java replit, Hello World
* Create first java replit, ''Hello World''
** Click run and get output.
** Click ''run'' and get output.
** Discuss the basic components of a java program.
** Discuss the basic components of a java program.
** Explain the syntax.
** Explain the syntax.
Line 12: Line 12:
** Variables
** Variables
** Primitive types and Expressions
** Primitive types and Expressions
** Introduction to numeric types: int, long, float, double.
** Introduction to numeric types: ''int, long, float, double''.
** Numeric operators: +-*/%
** Numeric operators: ''+-*/%''
** Useful constants like Math.PI
** Useful constants like ''Math.PI''
** Variable declarations and initialization
** Variable declarations and initialization
** String types: simple string creation, concatenation
** String types: simple string creation, concatenation
** Introduction to boolean types and operators. && || == !=, >, < etc.
** Introduction to ''boolean'' types and operators. ''&& || == !=, >, <'' etc.
** Some practice with these types- give a few simple programming problems
** Some practice with these types- give a few simple programming problems


=== Class 2 ===
=== Class 2 ===
* Recap boolean expressions
* Recap ''boolean'' expressions
* Introduction to while loops
* Introduction to ''while'' loops
** Using a variable to count loops
** Using a variable to count loops
** Simple programs using while()  
** Simple programs using ''while()''
*** Print the numbers 1 to 10
*** Print the numbers 1 to 10
*** Print the numbers 10 to 1
*** Print the numbers 10 to 1
** Incrementing, decrementing,  
** Incrementing, decrementing,  
* Introduction to if/else statements
* Introduction to ''if/else'' statements
** Simple conditional execution
** Simple conditional execution
** Combine ''if'' with ''while''. For example, print even numbers up to 20.
** Combine ''if'' with ''while''. For example, print even numbers up to 20.
* Introduction to Scanner and Random.   
* Introduction to ''Scanner'' and ''Random''.   
** Ask the user to input their name and repeat it back
** Ask the user to input their name and repeat it back
** Ask for a number and repeat back its square
** Ask for a number and repeat back its square
Line 37: Line 37:
With these two we can start to build a complex program: play a guessing game: choose a random number between 1 and 10 and have the user guess the number, giving too low/ too high feedback. This might require step-by step building up the program with the students.
With these two we can start to build a complex program: play a guessing game: choose a random number between 1 and 10 and have the user guess the number, giving too low/ too high feedback. This might require step-by step building up the program with the students.


Assign the fizz buzz problem for homework.
Assign the ''fizz buzz'' problem for homework.


=== Class 3 ===
=== Class 3 ===
* Fizz buzz solution
* ''Fizz buzz'' solution
* [SKIP] Do … while ⇔ while  
* [SKIP] ''do {} while'' ''while''
* Introduction to for loops
* Introduction to ''for'' loops
** do several examples
** do several examples
** While ⇔ for loop
** ''while'' ''for'' loop
* Objects and classes: usually we use a working example of Robots or Animals
* Objects and classes: usually we use a working example of Robots or Animals
** Member variables
** Member variables
Line 67: Line 67:
** Examples of state machines, inheritance
** Examples of state machines, inheritance
** Show example of a shooting state machine from the code.
** Show example of a shooting state machine from the code.
* Installing WPILib, github desktop
* Installing '''WPILib''', '''GitHub Desktop'''

Latest revision as of 11:13, 6 July 2024

TRC Beginner Programming Curriculum

Class 1

  • Introduction, overview: Everyone should bring a laptop to class. Student laptops are ok.
  • Set up [replit.com](https://replit.com/signup) accounts: Most students use their google account to sign in.
  • Create first java replit, Hello World
    • Click run and get output.
    • Discuss the basic components of a java program.
    • Explain the syntax.
    • Show a couple examples where the program breaks because of bad syntax. Explain the error messages.
  • Topics covered:
    • Variables
    • Primitive types and Expressions
    • Introduction to numeric types: int, long, float, double.
    • Numeric operators: +-*/%
    • Useful constants like Math.PI
    • Variable declarations and initialization
    • String types: simple string creation, concatenation
    • Introduction to boolean types and operators. && || == !=, >, < etc.
    • Some practice with these types- give a few simple programming problems

Class 2

  • Recap boolean expressions
  • Introduction to while loops
    • Using a variable to count loops
    • Simple programs using while()
      • Print the numbers 1 to 10
      • Print the numbers 10 to 1
    • Incrementing, decrementing,
  • Introduction to if/else statements
    • Simple conditional execution
    • Combine if with while. For example, print even numbers up to 20.
  • Introduction to Scanner and Random.
    • Ask the user to input their name and repeat it back
    • Ask for a number and repeat back its square

With these two we can start to build a complex program: play a guessing game: choose a random number between 1 and 10 and have the user guess the number, giving too low/ too high feedback. This might require step-by step building up the program with the students.

Assign the fizz buzz problem for homework.

Class 3

  • Fizz buzz solution
  • [SKIP] do {…} whilewhile
  • Introduction to for loops
    • do several examples
    • whilefor loop
  • Objects and classes: usually we use a working example of Robots or Animals
    • Member variables
    • Constructors
    • Member methods
    • Getters/setters
    • Static class methods
    • Inheritance - show some examples from FRC repos.
  • Arrays
    • Initialization
    • Iterating
    • Exercises: find the min, find the max, compute the average
  • Case statements
  • State machines
    • Soda vending machine
    • State transition diagram
    • What variables are needed,
    • Implementation as a class
  • Exceptions - throwing/handling
  • Wrap-up:
    • Tour of FRC code base.
    • Examples of state machines, inheritance
    • Show example of a shooting state machine from the code.
  • Installing WPILib, GitHub Desktop