Fundamentals of Programming

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

Chapter 6-1 Exercises

Name____________________________ Checked By: ____________________________

 

NOTE: This webpage gives an example for using an IF/ELSE statement similar to Exercise 3 (TallTrees)

 

  1. ___ / 9 pts Chapter 6-1, Example 1 - Zeus shooting bolts at Philosophers (requires 5-2 Example). [Page 160-165]
    • ____ [1 pt] Initial World - Zeus on a cloud, a hidden thunderbolt object, 4 Greek philosophers, smoke object (a special effect) below the ground out of sight. Name the file "CH6-1ZeusIF.a2w"
    • ____ [4 pts] Method - World.shootBolt with a parameter who and an if who==Homer shooting at Homer
    • ____ [2 pts] Method - World.shootBolt with logical operators (or) shooting only at the philosophers (Homer, Plato, Socrates, Euripedes)
    • ____ [2 pts] Method - World.shootBolt with nested if statements shooting only if the philosopher is not black
  2. ___ / 8 pts Chapter 6-1, Exercise 1 - Modified Ch6-1ZeusIF.a2w world to make each philosopher say something different when clicked. Name the file "CH6-1ZeusSAY.a2w"
    • ____ [2 pts] Euripides says “Come on guys, I wanna take a bath.”
    • ____ [2 pts] Plato says, “I call it… Play Doe” and then extends his right hand to show the other philosophers his Play Doe.
    • ____ [2 pts] Homer says, “By my calculations, pretzels go extremely well with beer. ”
    • ____ [2 pts] Socrates says “Like sands in the hour glass, so are the days of our lives.”
  3. ___ / 13 pts Chapter 6-1, Exercise 7 – TallTrees [page 169]
    • ____ [1 pt] Commenting
    • ____ [2 pts] Initial World - Alice object (or some other object positioned between two tall trees).
    • ____ [2 pts] Methods- Alice walking back and forth between the two trees.
    • ____ [2 pts] Events - Alice takes a step each time the user presses the enter key.
    • ____ [4 pts] Question (a Function with an If) - Alice should walk until she reaches a tree, if she as at the tree she should turn around to walk back toward the other tree. If she gets to the second tree, she should turn around to walk back towards the first tree.
    • ____ [2 pts] Be sure to avoid Alice colliding with one of the trees.

TOTAL SCORE: ______ / 30 points