begin()
First I will construct my array of four NoisyButtons called buttonList.
name a person construct yourself as a magenta NoisyButton – You are my buttonList[0].
name a person construct yourself as a blue
NoisyButton – You are my buttonList[1].
name a person construct yourself as a green
NoisyButton – You are my buttonList[2].
name a person construct yourself as a yellow NoisyButton – You are my buttonList[3].
Now I will construct a new Song.
name a person construct yourself as a new Song using my buttonList.
[ask the Song person] Make a new song.
[ask the Song person] Add a note to your song.
[ask the Song person] Add a note to your song.
[ask the Song person] Add a note to your song.
[ask the Song person] Play your song
Now I will wait for the User name a person to click on the mouse button
onMouseClick()
[name the User] clicked on a button.
Did you click on [name of person who is buttonList[i]]
If you did then I will set currentButton to equal [name of person who is buttonList[i]].
Otherwise I will ask the next button.
Now I will ask [Song person] what the expected note in the song is. [GetExpected] and save that as currentNote.
if currentNote matches currentButton then I will tell the Song to go to the next note. [nextNote].
if not then I will play a nasty noise!
Song
constructor(passed a NoisyButton array)
I am constructing myself as a new Song.
My current song length is 0.
My current expected note is 0.
I will store the array of NoisyButtons as myButtonList.
I will create array mySongNotes of NoisyButtons that has room for 100 notes.
I will ask the RandomIntGenerator [name a person] to construct themselves.
MakeNewSong
[ask the RIG] to get the next value.
I will make my first song note equal to myButtonList of this value [name the person who is that button].
I will make my current song length 1.
Play
I will construct a new SongPlayer [name a person], give them mySongNotes, and tell them to play my current song length number of notes.
AddNote
[ask the RIG] to get the next value.
I will make my next song note equal to myButtonList of this value [name the person who is that button].
I will add one to my current song length.
getExpected()
[name the person who corresponds to the expected note] is the current expected note.
next()
I will add one to my current expected note.
NoisyButton
constructor
I am constructing myself as a new NoisyButton.
flash()
I am playing my note and changing colors.
User
You simply click on NoisyButtons.
SongPlayer
constructor(song, number of notes to play)
Given the Song, I tell each button to flash from 0 to the number of notes to play.
RandomIntGenerator
constructor:
I am constructing myself as a new RandomIntGenerator
nextValue()
The next number is (0 to 3).