8. Focus Chimes
Lab today is the first step in completing our next assignment, which is to create an interface that captures a pattern of chime sounds, that a second person can try to replicate. While we are not doing all of it during today's lab, the completed app is described in the following video (2:25):
The components of the interface are shown below:
Activity
Activity
Start with the App Lab starter code given here. In lab today we will add the following three features:
- (1 point)
- When buttons A, B, C, or D are clicked add 1 to BtnCounter and play the appropriate sound.
- Create a variable called moveNumber and initialize it to 0. Each time buttons A, B, C, or D are clicked add one to the moveNumber variable and then display it in BtnCounter.
- For button A play Chime1.mp3, for button B play Chime2.mp3, for button C play Chime3.mp3, and for button D play Chime4.mp3.
- To play a sound use the UI controls playSound block. On the playSound block select the down-triangle / Choose / Make new sounds which is where you will find the sounds that have been preloaded for you.
- (1 point)
- Append the letter corresponding to the button pressed to LblHistory.
- Create a variable called moveHistory and initialize it to a single blank character. Upon each button press add the appropriate letter to the end of this variable (e.g. moveHistory = moveHistory + "A") and store this text in LblHistory using the UI controls setText(...) block.
- (Time permitting, 1 point extra credit)
- Implement the Reset and Cheat/Hide buttons.
- When Reset is selected, set the moveNumber to 0 and redisplay it, and also reset moveHistory to a single blank and store it again into LblHistory.
- Selecting BtnCheatOrHide should have the effect of toggling the display of LblHistory on and off as well as toggling the text in BtnCheatOrHide between "Hide" and "Cheat".
- To see if LblHistory is currently displayed you can check if getProperty("LblHistory", "hidden") == true
- You can show or hide LblHistory using showElement("LblHistory") and hideElement("LblHistory")
- When Reset is selected, set the moveNumber to 0 and redisplay it, and also reset moveHistory to a single blank and store it again into LblHistory.
Submission
Submission
Get the link to your group's solution using the Share near the top-left of that page:
Post the link to your App Lab solution using this google form. The title should be: Focus Lab. Be sure to type in all group member names on the submissions form as well as within your code!