CompSci 4 - Classwork 7 - Sep 18, 2007
10 pts

Today's classwork goes along with Chapter 4, Section 2. You will be writing methods with parameters and calling those methods with different arguments. In both cases think about what is the same and what needs to be in the method. Try to duplicate as little code as possible.

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

  1. Problem 5 - Beetle Band Duet

    1. Download the Alice file that has the Beetles setup on stage and the sounds for the instruments in the World. This file is on the CompSci 4 calendar page.

    2. Be sure to include comments with your names and the date in your world.myFirstMethod. They have been started for you.

    3. Write a method named duet where two band members jump together up and then back down while playing their band instruments. Parameters to send in include the names of the two band members and the names of their instruments.

    4. Have at least three calls to the duet method in your world.myFirstMethod with different arguments each time.

    5. Add one more parameter, the height they jump up.

    6. Add one more parameter, for both of the band members to be "saying" the lyrics to the song as they jump up and play their part. You can pick your own lyric, they might both say "Oooooooh Ooooooh yeahhhh!".

    7. Again, make sure your calls to the duet method in your world.myFirstMethod call with different arguments each time.

  2. Problem 6 - Frog Escape on page 111.

    Create a pond and three frogs sitting on the edge of the pond. Have a hungry snake enter the scene. Write a method that has the snake turn toward a frog, move toward it and have the frog jump into the pond.

    You may want to have the snake slide back after trying to get the frog. Then the snake is the correct position to try again to get another frog.

    You should have at least two parameters. Which frog to jump should be one of the parameters. You should decide on another parameter.

    You may need to go to the web search to add the pond. When you drop in the three frogs, they may be hard to find. Resize them and/or make them move up to find them. Then place them in front of the pond and resize back to their original size.

    Be sure to include comments with your names and the date in your world.myFirstMethod.

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