Objectives
- Familiarize with the conditions of realizing the Minesweeper case study.
- Study the initial specification of the Minesweeper application requirements.
- Distinguish the Java operators, understand their meaning and use.
- Familiarize with the importance and use of objects in programming.
Introduction
-
On the current and following exercises you will realize the Minesweeper case study.
Instructions
-
The exercise instructions will contain the sequences of steps leading to creating the Minesweeper application Minesweeper by using the Java technology, but the program itself will be created by you. In the study you will work continuously, therefore it is necessary to ensure the transfer of source codes to the next excercise. It is necessary to submit the Minesweeper application latest in the last week of the semester. The submitted application must contain all required properties and have the required structure following the exercise instructions. Documentation generated from the source codes and unit tests are also part of the submitted application.
-
Minesweeper is a computer game designed for one player. The objective of the game is to clear the mine field of mines without their detonation.. The client's requirement is to create a Minesweeper game. Detail information about the game can be found at www.wikipedia.org. Fortunately experienced collaborator will help you with some tasks and thus you won't start from scratch. For example in this exercise you collaborator delivered a class diagram, some source code and a few ideas.Note: Of course, acting in the role of the collaborator is your lector. (So you'd know who to appreciate:)
-
Create a new project in the NetBeans IDE environment with the name
Minesweeper
. Add the content of the minesweeper.zip archive into the project's src directory. (only for NetBeans IDE: Set the main class in the NetBeans IDE tominesweeper.Minesweeper
). If you run the created project, you will get an exception (java.lang.UnsupportedOperationException: Method generateField not yet implemented
). Despite the project cannot be compiled, the game will not be functional. Your task is to implemented the game. -
Familiarize yourself with the project packages.
-
The
minesweeper
packge is the basic package, contains the main application classes. -
The
minesweeper.core
package contains the classes defining the game field logic independent of the user interface. -
The
minesweeper.consoleui
package contains the classes defining the user interaction.
-
The
-
Familiarize yourself with the classes in the project, their hierarchy and relations.
-
The
Minesweeper
class is the main class of the application, contains themain
method. -
The
ConsoleUI
class defines the user interaction with the playing field. -
The
Field
class represents the playing field and its functionality. The playing field contains tiles. -
The
Tile
class represents a tile of the playing field. - The tiles are of two types: mine and mine search assistance.
-
The
Mine
class represents a tile of type mine. -
The
Clue
class represents a tile of type mine search assistance. -
Tile state is expressed by the
Tile.State
enumeration. -
Game state is expressed by the
GameState
enumeration.
OPEN
, coveredCLOSED
or marked by a flagMARKED
. The game can be running (statePLAYING
), be successfully finished (stateSOLVED
) or be unsuccessfully finished (stateFAILED
). -
The
-
Try switching between the source codes by pressing the „CTRL” key and simultaneously pressing the left mouse button (works on names of classes, variables, methods, etc.), or via the context menu upon the searched source by selecting the „Navigate > ...” item.Task: Open the class
Field
in the IDE. By using the „CTRL” key and simultaneous pressing of the left mouse button switch to theTile
class via the lineprivate Tile[][] tiles;
. -
Learn to search the places in the source code, where the particular method, field, variable or class is used. Set the cursor on the required place and select „Find Usages” from the context menu.Task: Search all places where the variableOpen the class
tiles
of theField
class is used.Field
in the environment. Set the cursor on the delaraton of the fieldtiles
and select „Find Usages” from the context menu.Task: Which data types are used in the project? Which ones of them are primitive?
Resources
- More detailed information about the Minesweeper game www.wikipedia.org
- Source code: minesweeper.zip