Objectives:
As
programs get longer it is useful to break them up into smaller pieces.
For example, in the First Encounter scenario can be divided into the three
pieces:
surprise: the spiderRobot and the alien surprise each other
investigate: the spiderRobot moves closer to investigate the alien
react: the alien hides and the spiderRobot sends a message
We write code (a method) for each of these pieces and the program will
simply use (call) each of the methods
Follow
the instructions on pp92-97 to write the method surprise and call this
method. You can, of course, do the same thing for the other two
methods if you wish.
| Assignment: Implement the Confused Kanga scenario on p 130 #2. |
Open
the BeetleBand world from the textbook examples. We are going to have
each of the band members play a musical solo. Follow
the instructions on pp100-103 to import a sound file for each instrument.
The sound files are located in the directory that you downloaded for the
course.
Since each band member performs similar actions, we will write a method called "solo". This method will take parameters telling it what band member, instrument, and sound file will be used. Follow the instructions on pp100-109 on how to use parameters.
| Assignment: Extend the Beetle Band scenario so that two members can play a duet, as described on p131 #5 Be sure that you use parameters to the duet method for which beetles are playing in the duet! |
| Assignment: Implement the Dragons playing chicken scenario on p133 #8 Be sure to use parameters for the two dragons and their height! |