Mine Sweeper is a strategy game that comes bundled with the MS Windows operating systems. Here's a screen shot of the game. At this point 26 seconds have elapsed and at least 8 of 10 mines remain hidden:
Note: It is possible that there are still 10 hidden mines.
Here's a screen shot showing the statistics dialog that appears at the end of a game:
Consult the help manual or play the game a few times to familiarize yourself with the rules.
Mine Sweeper Plugin (MSP) mimics Mine Sweeper. It is intended to show that not all plugins need to be productivity applications.
The New Game use case extends the New Model use case from the framework by allowing the player to choose the degree of difficulty: Easy, Medium, and Hard. This choice effects the size of the grid and the number of mines. The mined squares are randomly determined. A timer starts.
Player: Left clicks on a square to indicate that the square probably hides a mine.
MSP: Changes the color or icon of the square to indicate that it is marked. If the square hides a mine, then the number of hidden mines is decremented.
Player: Right clicks on a square to uncover it.
The game ends with a loss if the player uncovers a mined square.
The game ends with a win when the last square is uncovered or marked. In this case it is assumed that all marked squares are mined. The timer stops.
MSP should keep track of and display the fastest win time.
A playing field is an n x n table of squares. Different values of n should be allowed. A square has two attributes: mined and state. Mined is true if the square hides a mine.
The state transitions of a square are given by the following state diagram:
In addition, each square has between three and eight neighboring cells. (Why the difference?)
Mine sweeper is a plugin for the MVCWorkbench. The plugin follows the Model-View-Controller architecture. The view is a JPanel containing a JTable. The PlayingField implements the TableModel interface:
The controller (not shown) is a mouse listener. Multiple views of the same game should be allowed.