Lab, Chapter 9 Lecture 1 Name: _________________________________________ Date: _________________________________________ Exercises from Chapter 9 1. Complete Exercise 1. The wave: This exercise is to practice using For all in order. Create an animation that simulates some sports fans doing “ the wave”- a popular stadium activity. Create an initial scene where a coach, student1, teacher, and randomGuy2 are standing on the field in a stadium. All four of these people have the same subpart structure. Then create a list made up of the people objects in the scene. Use the For all in order statement to animate each person rising his or her arms to simulate “the wave”. HINTS: To put the arms down before the program starts to run use: leftArm roll left .2 rev rightArm roll right .2 rev FOR THE WAVE: Do together leftArm roll right .4 rev rightArm roll left .4 rev upperBody turn backward .08 rev. Page 1 of 2 2. Complete Exercise 3. Spring Flowers. If you have a copy of that world created in Chapter 5, the flowerbox, you can revise that world. Otherwise, build the world using a box and flowers. Five flowers (your choice) are hidden inside the box. Create a list, where each flower is one item of the list. (a) Make each flower grow one at a time using For all in order. [HINT: You can use the resize to make them grow.] (b) When you have that working well, create a second version where all flowers grow out of the flowerbox at the same time. Concept Questions (Short answer) 3. What benefit is gained in a program by using a list of objects? 4. Give a reason for making a list of objects a world-level, rather than a class-level, variable. 5. In the Rockette example world, all the items in the list were instances of the Rockette class. In Exercise 1 above, however, the items in a list are instances of different people. Having items in a list that are not instances of the same class could cause a problem when the program is executed. What do each of the items in a list need to have in common to avoid a problem at runtime? Page 2 of 2