Intro To Java Workshop
Section 3 (Alternate)
Variable Types
Complete the variable type activity to formally introduce variable types. Remind the students that they've already worked with an int variable (rocketY) and a boolean variable (mousePressed)
Robot Review
At the whiteboard, review with students how to instantiate a robot and the
penDown()
, move()
, turn()
methods.
Put students in pairs. Tell students that they will take turns running code and being the robot. Have students work together to write robot code, then one student will act out the move and turn commands. They will then run the code to see if they were corrrect.
Repeat Robot
- Teach students to write a while loop
- Show students how to write code to make a robot move and turn a bunch of times using a while loop
- Have students write the above code in RepeatRobot (zebra.section3 package)
- Tell students to try to make the coolest drawing they can. Tell them they can use
setRandomPenColor()
, use multiple Robots, change the angle that the robot turns, use a variable as a parameter for move/turn, etc. - At the end of class, have students go around and check out other students' creations