# CompSci 4 - Classwork 16- November 1, 2011 10 pts

Today's classwork goes along with Chapter 9, Section 1. You will be writing lists and manipulating them.

The following work needs to be checked off when you have completed it.

• First download the file listfun.a2w from the CPS 4 web page.

• Ignore the tennis balls for today's work until the last item. You do not need them for anything with the animals.

• Create a list with all six animals in it.

Note BUG in Mac: If you have a Mac, when you create the list, you can select an item to add to the list, but when you are ready to select an animal such as "entire Chicken", it will not let you click and select it. If you press enter, it will add the Chicken to the list.

• Write the following methods. You should use "For all in order" or "For all together" where appropriate. Then call all the methods to demonstrate that they work.

1. Method SpinOneAtATime

Spin each animal all the way around once.

2. Method jumpUpAndDownWhileWiggling

All the animals should do the following at the same time, jump up .25 meters and come back down to the ground. They should all wiggle their legs while they are in the air.

Note that all of these animals have the parts "rightLeg" and "leftLeg".

3. Method compareHeightsWithOnePlayer

This method passes in a parameter which is one of the animals. It then compares this animal with all the animals in the list, one at a time. Whenever it compares, if the heights are the same, the animals being compared should say "the same". If the heights are different, the one who is shorter should say "I'm shorter" and the one who is taller should say "I'm taller."

4. Method compareAllHeights

Compare all the heights of all pairs of animals. For each animal, you should have it say "Compare Me" and then compare it with all the other animals, one at a time by calling compareHeightsWithOnePlayer.