# Fundamentals of Programming

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

Chapter 5-2 Exercises

Name____________________________ Checked By: ____________________________

1. ___ /12 pts Chapter 5-2 Example - Hockey with Number Parameter [Page 138-141]
• ____ [1 pt] Commenting
• ____ [3 pts] Initial World -  Hockey Player (Jack), net, 1 puck, 3 power buttons, winter scene
• ____ [2 pts] Method - World.swing with one number parameter called power
• ____ [3 pts] Events - 3 events, one for each button
• ____ [3 pts] Play - player swings with 1/power speed, puck moves power distance based on button clicked
2. ___  /11 pts Chapter 5-2 Example - Zeus with Object Parameter [Page 141-146]
• ____ [2 pts] Commenting & storyboard (on back of this sheet)
• ____ [3 pts] Initial World -  Zeus on a cloud, a hidden thunderbolt object, 4 Greek philosophers, smoke object (a special effect) below the ground out of sight
• ____ [2 pts] Method (EventHandler)- World.shootBolt with Object parameter who.
• ____ [4 pts] Event - user clicks on Philosopher, Zeus points & shoots lightning bolt, then bolt returns to Zeus
• ____ [2 pts] Bonus - return lightning bolt invisible by _______________________ technique
3. ___ /10 pts Chapter 5-2 Exercise - Carousel Go-Round [Page 147]
• ____ [2 pts] Commenting & Storyboard (on back of this sheet)
• ____ [2 pts] Initial World - amusement park scene with a carousel with 4 animals, switch.
• ____ [2 pts] Method (Event-handler) - World.clockwise makes the carousel rotate clockwise.
• ____ [2 pts] Method (Event-handler) - World.counterclockwise makes the carousel rotate counter clockwise.
• ____ [1 pt] Event - clicking green button turns carousel clockwise
• ____ [1 pt] Event - clicking red button turns carousel counter clockwise
4. ___ / 11pts  Chapter 5-2 Exercise - Snow Festival
• ____ [2 pts] Commenting & Storyboard (on back of this sheet)
• ____ [3 pts] Initial World - snowman, 4 colored spotlights
• ____ [4 pts] Method (eventHandler) - World.changeColor with parameter that will changes the snowman to the color of the light
• ____ [2 pts] Event - Clicking on any light changes the color of snowman
5. ___ / 13 pts Chapter 5-2 Exercise 4 - Penguin Slide
• ____ [2 pts] Commenting
• ____ [3 pts] Initial World - 3 Penguins, icy slope, frozen pond
• ____ [4 pts] Method (eventHandler) - World.penguinSlide with: a parameter that will represent the penguin that is clicked and a parameter that will represent the number of times the penguin is to spin
• ____ [4 pts] Event - clicking on any penguin will make that penguin spin and slide down slope then disappear .

TOTAL SCORE: ______ / 57  points