2A beetle bandOur task is to create an animation for a bug band as an advertisement for their next concert.
3Storyboards Each bug band member will perform a solo. Do together Do in ordergeorgeBeetle move upgeorgeBeetle move downplay soundDo togetherDo in orderringoBeetle move upringoBeetle move downplay soundDo togetherDo in orderpaulBeetle move uppaulBeetle move downplay soundDo togetherDo in orderlennonBeetle move uplennonBeetle move downplay sound
4DemoBeetleBand-v1Concepts illustratedTo play a sound, a sound file must first be imported into Alice. (Alice is not a sound editor.)This code is only for georgeBeetle.Three more methods (one for each band member) will be needed!
5A Better SolutionFour versions of very similar code seems a bit tedious. The only things that change are the beetle and the music that plays.A better solution is to write a more flexible method.
6ParametersBuilt-in methods provide information by providing parameters such as distance and direction.Parameters allow you to pass in values (Arguments).ExampleParameters: distance, directionArguments: 0.5 meters, 0.5 seconds
7Kinds of ParametersAlice provides several kinds of parameters that can be used in your own methods.
8The storyboard In this example, we can write just one method and use parameters to specify:which band member is to perform andwhich music should be played.soloParameters: bandMember, musicDo togetherDo in orderbandMember move upbandMember move downplay music
9Demo Ch04Lec2BeetleBand-v2 Concepts illustrated Enter name and select the type of each parameterbandMember is an object parametermusic is a Sound parameterA parameter acts as a placeholder in the instructionArgument are passed to the parameterin the call to the method
10A Number parameterAdd a Number parameter to specify the height the bandMember jumps up and down.Note that the call to the method must now include an argument for the height.Traditional Lecture: Demo adding a number parameter for the height of the jump.Active learning: Students add the number parameter and revise the statement to call the method.
11Assignment #1: Beetle Band Duet 1.The Beetle Band example has a method names solo where each member jumps and plays a musical instrument. Recreate the Beetle Band example and write a method named duet, where the solo method is called to have two members of the band jump together and play their musical instruments.2. This exercise can be done with sound or with lyrics. Parameters must be used to send in the name of the band member and the music to be played or the lyric to be said.