Class Work
Topic 5-2: Events with Parameters

Complete Chapter 5, exercise 14 on page 140  or exercise 15 on page 141 from the Learning to Program with Alice textbook. The problems are restated here for those who do not have the book.

The purpose of these exercises are to create events that use parameters.

Option 1: Penguin Slide. A favorite activity of penguins at a local zoo is to slide down an icy slope into a pool of water in the pond. Create a world with a lake scene and three or more penguins on a slope. (You can either use the lake from the Environments folder or create a simple scene with various shapes from the Shapes folder.) Make the program event driven. This means when the user clicks on a penguin that penguin should slide down the slope into the pool of water. Each penguin should slide on its belly and spin around as it slides. The slide does not have to conform exactly to the hillside. When the penguin reaches the pond move the penguin down enough so that it disappears in the water.

Write only one event handler method. When the penguin is mouse clicked, pass the penguin that was clicked to the method that handles the sliding.

Click here to download an initial penguin world.

 

 

Option 2: Hockey Game. Create an interactive hockey game. Create a scene with a person on a lake. Set up a hockey net and give the person a hockey stick (both in the sports folder). Create 3 buttons (bumps from the shape folder) that determine how hard the player swings the stick and how fast the puck (another bump) travels towards the net.

Click here to download an initial hockey world.