Bouncing Ball

SAMPLE APPLET:

Similar EXAMPLE

ASSIGNMENT: You will need to study the following code carefully!!! Here is what you should do:

  1. Get the sample running
  2. Notice the implements Runnable and the run methods. Figure out what the variables are for (especially xDir, incr, and sleepFor).
  3. Understand why and when the ball changes directions. (That's the if statement in the run method ... the || means OR.)
  4. Alter this applet so the ball moves up and down (in a tall and skinny applet area).