CompSci 94 - Classwork 7 - Sep 17, 2013
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. Beetle Band Duet

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

    2. Be sure to include comments with your names and the date in the main method, world.myFirstMethod.

    3. Write a method named duet where two band members jump up together and then back down while playing their band instruments (both sounds should be played at the same time). Note that the instruments are already vehicled to the beetle that plays them, so an instrument will move up with the beetle automatically.

      This method should have FOUR parameters:

      • two band members - each of type object
      • two instrument sounds - each of type Sound

    4. Have at least four calls to the duet method in your world.myFirstMethod with different arguments each time. Make sure the beetle plays the sound of the instrument he is holding. You can find the instrument sounds under "world", "properties", "sounds". Expand the "+" beside sounds. Play it and make sure this works.

    5. Add two more parameters of type String, 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!".

    6. Again, make sure your calls to the duet method in your world.myFirstMethod call with different lyrics each time. Play it and make sure this works.

    7. Add two more parameters of type object for the band instruments of the band members. When the band member jumps up, the instruments should be spun around and as they come down spun around in the opposite direction.

    8. Again, make sure your calls to the duet method in your world.myFirstMethod call with different instruments each time, they should correspond to the band member who is holding that instrument. Play it and make sure this works.

      You should have a total of eight parameters for the duet method when done.

  2. Escape from Snake

    Create a pond with three frogs from the animals folder. Change the color of two of the frogs so that the frogs are all different colors. All the frogs should be sitting on the edge of the pond in different parts but all between the camera and the water. Have a hungry snake enter the scene from where the camera is. The pond can be the Oasis in the Environments folder or a shape from the Shapes folder (you can change the color to blue).

    When you drop in the 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 in different positions (one to the far left, one in the center and one to the far right).

    Write a method that has the snake turn toward a frog, and move towards it, the frog jumps into the pond and the snake slithers back to where it was. You want the snake in the correct position to try again to get another frog.

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

    In world.myFirstMethod your new method should be called three times, once for each frog.

    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.