Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

This is in Java . I just need the void clearBlanks method . Requirements Minesweeper is a two dimensional grid that has mines hidden randomly

This is in Java. I just need the void clearBlanks method .

image text in transcribed

image text in transcribed

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 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. will reveal all of the adjacent blank cells. If any of the cells have mines 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 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. mnes 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 start0: 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 gameLoop0: 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: . randomFillGrid0: This method will randomly place mines in the grid. . displayGrid0: This method will display the grid with the hidden and revealed cells. displayGridData0: 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 y There are some sample screenshots in a following section. Screen Shots These screen shots are examples of what your application should look like. our project. 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. 123 456789 10 k i * t k k i x ; t i k x * i i k i k * * i k i i * i t i k i x * t k i x *k k i * t k k i x ; t 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. 123 456789 10 i k x * i 2 4 2222222 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 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. will reveal all of the adjacent blank cells. If any of the cells have mines 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 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. mnes 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 start0: 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 gameLoop0: 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: . randomFillGrid0: This method will randomly place mines in the grid. . displayGrid0: This method will display the grid with the hidden and revealed cells. displayGridData0: 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 y There are some sample screenshots in a following section. Screen Shots These screen shots are examples of what your application should look like. our project. 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. 123 456789 10 k i * t k k i x ; t i k x * i i k i k * * i k i i * i t i k i x * t k i x *k k i * t k k i x ; t 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. 123 456789 10 i k x * i 2 4 2222222

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Reliability Engineering Designing And Operating Resilient Database Systems

Authors: Laine Campbell, Charity Majors

1st Edition

978-1491925942

More Books

Students also viewed these Databases questions

Question

What is meant by institutional school of responsibility? Explain.

Answered: 1 week ago

Question

1 What are the dimensions used in Hofstedes model of culture?

Answered: 1 week ago