

There’s also a ticking clock: if you take too long, the mines will go off. In which case, multiple squares without mines might be revealed at once. And, on the easy or medium setting, the mines tend to be away from the corners. I usually begin by left-clicking on a corner square. Each square either has a mine or it doesn’t, but at the beginning of the game, you don’t know which is which.

You’re presented with a rectangular formation of squares. I will quickly describe the GUI version just in case you recall it only vaguely, or if you’ve never played it. For example, “!” can indicate a flagged position, “X” can indicate a detonated mine, etc. Since the primary purpose of the famous Microsoft Windows Minesweeper game was to familiarize users with the left and right mouse buttons, and how to use them to indicate items on a screen, most people are aware of Minesweeper only as a game with a graphical user interface (GUI).īut it’s certainly possible to make the game with a command line interface, even one limited to ASCII characters. Here I suggest Minesweeper on the command line in particular as a very good exercise for Java beginners to learn about object-oriented programming and the benefits of separating content from presentation. The program requirements for a game are easy to explain and the student can get immediate feedback on their program by playing the game. Games in general are often given as an answer. Beginners in Java often ask for good projects with which to learn Java and the principles of object-oriented design.
