Data types (Minesweeper Task 1)

Objectives
  1. Familiarize with the conditions of realizing the Minesweeper case study.
  2. Study the initial specification of the Minesweeper application requirements.
  3. Distinguish the Java operators, understand their meaning and use.
  4. 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
  1. 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.
  2. 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..
    Fig.: The Minesweeper game
    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:)
  3. 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 to minesweeper.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.
  4. 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.
  5. Familiarize yourself with the classes in the project, their hierarchy and relations.
    • The Minesweeper class is the main class of the application, contains the main 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.
    The following figure is a class diagram.
    Fig.: Class diagram of the Minesweeper game
    A tile can be in the state uncovered OPEN, covered CLOSED or marked by a flag MARKED.
    Fig.: State transition diagram of a tile
    The game can be running (state PLAYING), be successfully finished (state SOLVED) or be unsuccessfully finished (state FAILED).
    Fig.: State transition diagram of the game
  6. 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 the Tile class via the line private Tile[][] tiles;.
  7. 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 variable tiles of the Field class is used.
    Open the class Field in the environment. Set the cursor on the delaraton of the field tiles and select „Find Usages” from the context menu.
    Task: Which data types are used in the project? Which ones of them are primitive?
Resources
  1. More detailed information about the Minesweeper game www.wikipedia.org
  2. Source code: minesweeper.zip
comments powered by Disqus