Fundamentals of Programming

"Success is the ability to go from one failure to another with no loss of enthusiasm." Winston Churchill

Chapter 3-2 Exercises

Name____________________________ Checked By: ____________________________

  1. ___ / 11 pts Chapter 3-1, Exercise 2 Gallop and Jump [Page 69]
    • ____ Commenting (3 pts)
    • ____ Initial World - horse with rider and a fence (1pt)
    • ____ Method - World.gallop to make horse and rider gallop forward one step (4 pts)
               horse’s front legs should lift and then go down as the back legs lift
              and the horse moves forward then the back legs should go back down
    • ____ Method - World.jump makes the horse should gallop and move up far enough to clear the fence in mid-stride (3 pts)
  2. ___ / 17 pts Chapter 3-2, Exercise 1 – FrogEscape [Page 85]
    • ____ Commenting (3 pts)
    • ____ Initial Scene (frogs, snake, pond, plants) (4 pt)
    • ____ Method - World.jumpingFrogs makes all the frogs jumping into pond (but not disappear) when snake appears (4 pts)
    • ____ Method - Snake.approach moves the snake toward any frog then frog turns and jumps into pond (4 pts)
    • ____ Parameter - in Snake.approach makes the snake turns toward a selected frog (parameter) and only that frog turns and jumps in pond (2 pts)
  3. ___ / 12 pts Chapter 3-2, Exercise 2– FunnyRace
    • ____ Commenting (2 pts)
    • ____ Initial scene - 3 characters in a row with start and stop lines (1 pt)
    • ____ Method - World.move simultaneously makes each character move forward to pass the finish line. (3 pts)
    • ____ Parameters - Use six parameters in the World.move. Three Objects parameters, one for each character, and three Number parameters that specify the amount of time (duration) for each of the three characters to complete the race. (6 pts)

  4. ___ / 10 pts Chapter 3-2, Exercise 3– Dragons
    • ____ Commenting (2 pts)
    • ____ Initial scene - 4 dragons in a diamond- like pattern so any dragon is an equal distance from each other (2 pts)
    • ____ Method World.dragonFlight- two dragons face each other and
               fly upward to a slightly different height above the ground.(4 pts)
               Then, the dragons fly towards each other, nearly missing one another.
               Each land in the position where the other dragon was located.
    • ____ Four parameters – in World.dragonFlight, the two parameters for dragons that will face off in a game of chicken and the two heights for each of the dragon’s flight (2 pts)

TOTAL SCORE: ______ / 50 points