Question
Java language 1. Design a 2-dimensional array of booleans as a minefield for minesweeper game; true indicates that the mine is present. boolean [ ][
Java language
1. Design a 2-dimensional array of booleans as a minefield for minesweeper game; true indicates that the mine is present. boolean [ ][ ] minefield = new boolean [10] [10]; then we need to calculate the number of neighboring squares that contains mines for each square int [ ] [ ] minedNeighbors = new int [10] [10];
2. Create a MineField class with fields to store the locations of mines and how many mined neighbors a given square has. Create a unit test to develop the following code using test unit @Test: - a constructor method that takes three parameters: number of rows, number of columns, and maximum number of mines, it also initializes the arrays. Write an existence test for this method. - a mineTile method with two parameters: rows and columns coordinates, that sets the tiles to be mined and increment the neighboring mine totals of the surrounding tiles using for loops which return true if the square was successfully mined and false if it exceeded the maximum number of mines or the square is already mined. Write a test for this method as well. - a populate method to randomly scatter the mines across the minefield (exclude(0,0) tile) by calling the mineTile method. Write a populate test to check the correct number of mines are generated. -create toString method to return the minefield represented by a string using " * " as a mine, and include the number of neighboring mines for unmined tiles, e.g: 00011212*1 1*11*22210 create a test for this method against minefields of differing mine numbers.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started