Minesweeper is a two dimensional grid that has mines hidden randomly throughout the game space. The...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
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 detemine 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. • 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 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. 12345 6789 10 ****** **** ********** ***** ***** 3. **** *** 4 客* 率* 6. ***** ***** 7 ******** 8. ***** ** 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. 1234 5 6789 10 ********** 1 2 ** 42222222 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 detemine 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. • 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 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. 12345 6789 10 ****** **** ********** ***** ***** 3. **** *** 4 客* 率* 6. ***** ***** 7 ******** 8. ***** ** 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. 1234 5 6789 10 ********** 1 2 ** 42222222
Expert Answer:
Answer rating: 100% (QA)
Answer MineSweeperjava package minesweeper public class MineSweeper public static void mainString args create game object Game g new Game start the ga... View the full answer
Related Book For
Posted Date:
Students also viewed these accounting questions
-
In each game following, what happens if Jack goes first? 1. 2. 3. 4. 5. 6. 7. 8. Jack's Strategy Left Jack gets 1 Jill gets 1 Right Jack gets4 Jill gets 2 Up Jill's Strategy Jack gets 2 Jack gets 3...
-
In each game following, what happens if Jill goes first? 1. 2. 3. 4. 5. 6. 7. 8. Jack's Strategy Left Jack gets 1 Jill gets 1 Right Jack gets4 Jill gets 2 Up Jill's Strategy Jack gets 2 Jack gets 3...
-
A spinner from a board game randomly indicates a real number between 0 and 10. The spinner is fair in the sense that it indicates a number in a given interval with the same probability as it...
-
Hybrid Corporation began operations in 2018 and during that year purchased equity investments. It owns less than 20% of the voting shares for all companies whose stock it purchased. The year-end cost...
-
Consider a single observation X from the Cauchy distribution with unknown location parameter . That is, the p.d.f. of X is Suppose that it is desired to test the following hypotheses: H0: = 0, H1: ...
-
Suppose you are a financial analyst and your company runs many simulation models to estimate the profitability of its projects. If you had to choose just two measures of the distribution of any...
-
Owing to economical sample sizes and ease of application, probability-proportional to-size (PPS) sampling has become the most widely used statistical sampling plan in practice today, even by local...
-
Gardner Industries manufactures and sells three different models of wet-dry shop vacuum cleaners. Although the shop vacs vary in terms of quality and features, all are good sellers. Gardner is...
-
Probability Probability Probability 1. The graph below provides a comparison of alternative techniques a US multinational company can use to hedge a receivable of SF200,000 in six months. The...
-
Cusic Music Company is considering the sale of a new sound board used in recording studios. The new board would sell for $26,400, and the company expects to sell 1,500 per year. The company currently...
-
SUBJECT: ACCOUNTING The owner got some goods costing P450 but priced to sell for P500 to be given as a gift to a friend. What is the journal entry based on perpetual system
-
Fill in the missing values: Do not enter commas , % or $ signs. Remember to use 2 decimal places for all of your answers. Calculating Cost of Food Sold Food Sales $ 1 1 5 , 2 5 0 . 0 0 Opening...
-
Consider a 10 year bond with face value $1,000, pays 6% coupon annually and has a yield-to-maturity of 7%. How much would the approximate percentage change in the price of bond if interest rate in...
-
Meyer Appliance Company makes cooling fans. The firm's income statement is as follows: Sales (7,000 fans at $20) $140,000 Less: Variable costs (7,000 fans at $8) 56,000 Fixed costs 44,000 Earnings...
-
Business tax senario: XYZ corporation made a profit of $ 5 0 0 , 0 0 0 . However, after business expenses and deductions, the taxable income is $ 3 0 0 , 0 0 0 . Calculate the corporation's tax...
-
Individual taxt payer senario: Jhon a freelance graphic designer, earned $ 8 0 , 0 0 0 i n the last financial year. H e has expenses amounting t o $ 2 0 , 0 0 0 . Calculate his taxable income, c o s...
-
There is almost as much written on the subject of motivation as there is on leadership. Google search on motivation and several hundred thousand links appear. So it is a topic very well researched...
-
Write electron configurations for the following ions, and determine which have noble-gas configurations: (a) Cd2+ (b) p3- (c) Zr4+ (d) Ru3+ (e) As3- (f) Ag+
-
Which is better for consumers, the direct subsidy of problem 18 or the excise subsidy of problem 19? Be sure to justify your answer.
-
In 2011, Hurricane Sandy caused widespread devastation throughout the Eastern U.S., leaving many desperate to acquire basic necessities such as food and ice (for food storage). Profiteers soon...
-
In each game following, identify all of the Pareto optima. 1. 2. 3. 4. 5. 6. 7. 8. Jack's Strategy Left Jack gets 1 Jill gets 1 Right Jack gets4 Jill gets 2 Up Jill's Strategy Jack gets 2 Jack gets 3...
-
A distribution-free test makes _____.
-
A slider-crank mechanism is used to impart motion to the base of a spring-mass-damper system, as shown in Fig. 4.38. Approximating the base motion \(y(t)\) as a series of harmonic functions, find the...
-
How does the null hypothesis tested by the Wilcoxon-Mann-Whitney test differ from the one tested by a standard independent groups t test?
Study smarter with the SolutionInn App