Intro To Java Workshop
Section 2 (Alternate)

Circle Activity

Before class, print this file (editable version here) and cut pages so that each piece of paper contains one graph or one code fragment. Shuffle them.

At the white board, review with students how to call the circle() method and what each parameter controls. Note that this exercise assumes we're using ellipseMode(CENTER), meaning that the first two paramters specify the center of the circle.

Distribute cards to students, or lay them all out on a table. Ask them to work together to pair the code fragment with the circle it draws. Once they've completed the pairs, ask each student to present one of the pairs and explain why the code and the image match.

Rocket Review

Ask students to open up Rocket.pde (which they did the day before) and write the line of code that moves the rocket (e.g. rocketY = rocketY - 10). Explain the variable:

  • Write the code "int rocketY = 600;" on the board, and put a piece of paper saying "600" in a box. Have someone hold the box and say "Hi, I'm rocketY, and my value is..." then pull out the paper and say "600"
  • Tell students they can ask the variable for its value if they call it by name, and prompt a few students to say "rocketY". rocketY should respond by saying "600"
  • Write the code "rocketY = 500;" on the board, and explain that this gives a new value to rocketY. Write "500" on a new piece of paper and put it in the box. Prompt a few more students to ask rocketY for its value.
  • Ask a student to come to the board and write code to give a new value to rocketY. Encourage the rest of the class to help them. Act it out once they have written the code.
  • Write the code "rocketY = rocketY - 10" on the board, and act it out a few times.

If Dice Activity

Do this activity to introduce if blocks. Then introduce mousePressed, which students will use in Tash Me.

  • Explain that mousePressed is a variable like rocketY, but a different kind of variables whose value is 'true' or 'false' instead of a number
  • Introduce yourself as the mousePressed variable, and tell students you will tell them your value if they call your name
  • Have one student come up and press a mouse that you draw on the board.
  • Have the class call out "mousePressed" as they like. You yell back "true" or "false" depending on what the mouse-pressing student is currently doing

Tash Me

Complete the Tash Me recipe. Starter code is provided to the students in package zebra.section2. The instructions are the same as the usual Tash Me recipe, but images are included in the data folder (face0.jpg, face1.jpg, etc.) so students can choose a face without having to use the internet. Instructions for finding their own face on the internet are included as a bonus.