Final Project, Points: 200        Overview    We are going to do a clone of the Minesweeper Game.  

    Requirements  

Minesweeper is a two dimensional grid that has mines hidden randomly throughout the game space. The player guesses a cell in the grid. If the cell has a mine in it the mine goes off and the game is over. If the cell does not have a mine in it the game will reveal all of the adjacent blank cells. If any of the cells have mines adjacent to them then a number is placed in that cell that indicates how many mines are adjacent. Once all the blank cells and cells with numbers have been revealed the player is given the opportunity to guess at another cell. Once all of the non-mine cells have been revealed the player wins.

Our game will have ten (10) cells with mines in it.

The initial filling of the grid will be done with a random generator to determine the location of the cells with mines.

The game will ask the player for a height and width to create the minefield two dimensional grid.

For this assignment we will use three classes, the main minesweeper class, a game class and a grid class.

The minesweeper class will have the main method in it and will create a new game object and call the start method out of the game object.

The game class will have the following methods: void start(): This method will be the starting point of the game. It will need to ask the user to input the height and width of the grid, initialize the grid using the height and width, and call the gameLoop void gameLoop(): This method will be the main loop that runs the game. This method will ask the user to input the cell that they want to check and will call the checkLocation method passing the cell location that the user just inserted. int numberOfMines(int row, int col): This method will count the number of mines that are adjacent to the cell that is at the location given by the row and col values passed to it. boolean checkLocation(int row, int col): This method will check if the location that is given by the row and col value has a mine. If it does not then it will call the clearBlanks method giving the current location.  void clearBlanks(int row, int col): This method will reveal all of the cells that are adjacent to the cell at the location given by the row and col values. If one of the adjacent cells has a mine adjacent to it, then a number will be put in that cells location that corresponds to the number of mines that are adjacent. If one of the adjacent cells does not have any mines adjacent to it, then that cell will be turned into a blank and the cells around it will be revealed and checked for mines. This process will continue until the only cells left all have numbers indicating the number of mines.

The grid class will have a constructor that takes two parameters, a height and a width. It will also have the following methods: randomFillGrid(): This method will randomly place mines in the grid. displayGrid(): This method will display the grid with the hidden and revealed cells. displayGridData(): This method will display the grid with the locations of the mines revealed.

The previous list of methods is a minimum requirement. You can have more methods than these. However, these methods must appear and be used in your project.

There are some sample screenshots in a following section.  

Screen Shots   These screen shots are examples of what your application should look like.

run: Enter the height of the grid: 10 Enter the width of the grid: 10 There are a total of 10 mines in the mine field.    

        12 3 4 5 6 7 8 9 10 * * * * * * * * * *

* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *

* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * ************** **************

Pick a spot to check for a mine. First enter the row number then the column number: 10 10 There are a total of 10 mines in the mine field.    

1 2 3 4 5 6 7 8 9 10 * * * * * * * * * * * * 4 2 2 2 2 2 2 2 2 1                                                                                                                  

Pick a spot to check for a mine.

First enter the row number then the column number:

1

5

There are a total of 10 mines in the mine field.     

1 2 3 4 5 6 7 8 9 10 * * * * 2 * * * * *

2   * * 4 2 2 2 2 2 2 2

3    2 2 1                                                     

Pick a spot to check for a mine.

First enter the row number then the column number:

1

8

There are a total of 10 mines in the mine field.     

12 3 4 5 6 7 8 9 10 * * * * 2 * * 2 * * * * 4 2 2 2 2 2 2 2 2 1              

4                       

5                       

6                        

7                        

8                      

9                        

10                       

You Win!

BUILD SUCCESSFUL (total time: 2 minutes 52 seconds)

run:

Enter the height of the grid:

10

Enter the width of the grid:

10

There are total of 10 mines in the mine field

12345678910 * ********* * ********* *********** *********** *********** *********** *********** *********** *********** ***********

Pick a spot to check for a mine.

First enter the row number then the column number:

1

1

GameOver!

There are a total of 10 mines in the mine field

                12345678910 * .* * . . . . . * . . * . * . . . . * * * * . . . . . . . ………………….. …………………… ………………….. …………………. …………………. …………………. ………………….

BUILD SUCCESSFUL (total time: 4 seconds

"Get 15% discount on your first 3 orders with us"
Use the following coupon
"FIRST15"

Order Now