String Processing

Programming Module

Recall the notation used in the drum machine module:

  • (X) represents a base drum
  • (x) represents a snare drum
  • (r) represents a rest.

Write a program that takes a string from the user that represents a beat pattern. Then play the beat represented by the pattern. Your program should validate that the input only contains 'X','x','r' prior to playing the beat. If the input contains another character display an error and prompt the user again. Otherwise, if the input was valid, then play the beat represented by the pattern multiple times.

note*: Remember that you need to call a wait method after each time you call playBase() or playSnare()