Excerpt from Description of Exercise

Objective: To gain experience working with arrays.

Many of you are probably familiar with the electronic toy named ``Simon''. Simon is a simple solitaire memory game. The toy is composed of a plastic base with four colored plastic buttons on top. Each button has a different color and a different musical note is associated with each button. The toy ``prompts'' the player by playing a sequence of randomly chosen notes. As each note is played, the corresponding button is illuminated. The player must then try to play the same ``tune'' by depressing the appropriate buttons in the correct order. If the player succeeds, the game plays a new sequence identical to the preceding sequence except that one additional note is added to the end. As long as the player can correctly reproduce the sequence played by the machine, the sequences keep getting longer. Once the player makes a mistake, the machine makes an unpleasant noise and restarts the game with a short sequence.

For this laboratory exercise, we would like you to write a Java program to allow one to play a simple game like ``Simon''. Like the original, our game will involve four buttons which the player will have to press in an order determined by the computer. Given the limitations of Java's layout managers, we will keep the graphics simple by simply placing the four buttons in a 2 by 2 grid as shown below.

Handouts Describing the Exercise

Student Resources for Lab Exercise

Sample solutions