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:

Focus Chimes app components

Activity

Start with the App Lab starter code given here. In lab today we will add the following three features:

    1. (1 point)
    2. When buttons A, B, C, or D are clicked add 1 to BtnCounter and play the appropriate sound.
      1. 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.
      2. 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.
      3. 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. (1 point)
  2. Append the letter corresponding to the button pressed to LblHistory.
    1. 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.
  3. (Time permitting, 1 point extra credit)
  4. Implement the Reset and Cheat/Hide buttons.
    1. 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.
      1. 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".
      2. To see if LblHistory is currently displayed you can check if getProperty("LblHistory", "hidden") == true
      3. You can show or hide LblHistory using showElement("LblHistory") and hideElement("LblHistory")

Submission

Get the link to your group's solution using the Share near the top-left of that page:

Share Link

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!