CompSci 4 - Classwork - Sep 19, 2006
5 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.
- Problem 5 - Beetle Band Duet
- 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.
- Be sure to include comments with your names and the date in your
world.myFirstMethod. They have been started for you.
- 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.
- Have at least three calls to the duet method in your
world.myFirstMethod with different arguments each time.
- Add one more parameter, the height they jump up.
- 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!".
- Again, make sure your calls to the duet method in your
world.myFirstMethod call with different arguments each time.
- Problem 7 - Magic Act on page 112. You can feel free to pick
your own assistant, your own table your setting (room, grass, etc.).
Be sure to include comments with your names and the date in your
world.myFirstMethod.
Essentially, your magician should point at an object which should
rise up and then go back down. Then the magician should turn and point
at another object of a different size. This object should rise up and
then down again, rising up more if it is a lighter object and rising
up less if it is a heavier object.
If you finish early, feel free to embelish your animations.