CSSE 220 – Object-Oriented Software Development

Linear Lights Out

Objectives

More practice with event-based programming in Swing.

Tasks

Linear Lights Out: Implement the game Linear Lights Out in the linearLightsOut project. In Linear Lights Out, the user is presented with an array of buttons that are randomly initialized to either Xs or Os, 50% probability each. Clicking on a button changes the symbol of the button and both its left and right neighbors, if they exist. Buttons on the end just change their own symbol and their one neighbor’s symbol; the buttons don’t “wrap around”. The object of the game is to reach a state where the buttons all show the same symbol, whether Xs or Os, it doesn’t matter.

We’re providing a lot less “scaffolding” for this problem than most of the previous ones. Everything you need to solve the problem has either appeared in previous homework or examples, or is in the Java API documentation for JButton. Remember to ask for help if you get stuck.

Here are the various stages you should complete:

Hints:

  1. The setText() and getText() methods of JButton are your friends.
  2. You do not need to use inheritance to solve this problem; your BallWorlds project will give you practice with that.

Here’s a screen shot of the game in progress:

Remember, in all your code:

Rubric

  1. Linear Lights Out - 10 points for each stage

Total: 70 points

Turn-in Instructions

Turn in your programming work by committing it to your SVN repository.