CompSci 4 - Classwork - Nov 22, 2005
5 pts

Today's classwork goes along with Chapter 10, section 2. You will be manipulating an array.

  1. In a new Alice world, add 6 different people to the world. Then add in an ArrayVisualization and initialize it with the six people from your world.

  2. Write a world method called PrintAllHeights that prints the heights of all the people in the array. You should use loop (complicated version) and print the height of the item in the index position of the array. That is, there should be just one print statement in the method.

  3. In world.myfirstmethod, call the PrintAllHeights method and note which person is the shortest and which is the tallest.

  4. Write the world function objectWithTallestHeight that returns the object in the array that has the tallest height. You should use a loop (complicated version) to go through the array and determine which one is the tallest.

  5. In myfirstmethod, add code that calls objectWithTallestHeight and makes the person with the tallest height turn around once.

  6. In myfirstmethod, add code that makes one of the people who is not the tallest person in the array to resize to be twice as big. Follow that with code that calls objectWithTallestHeight and makes the person with the tallest height turn around once (it should be a different person this time).

  7. Write the world function indexOfSmallestHeight that returns the index position of the person in the array with the smallest height. (note this returns the index, not the object).

  8. Add code to the beginning of world.myfirstmethod to make the person with the smallest height move up one meter and then move down one meter. You should call indexOfSmallestHeight to determine where the smallest person is.

  9. In world.myfirstmethod, right after the code that resizes someone to twice as big, add code to resize a different person who is not the smallest, to resize to 1/2 their size.

  10. At the end of world.myfirstmethod, add code to make the smallest person go up one meter and then go down one meter (it should be a different person this time).

If you finish early, feel free to embelish your animations.