Write a program Minesweeper_YI.java that takes 3 input arguments m, n, and p and produces an m-by-n boolean array where each entry is occupied with probability p. In the minesweeper game, occupied cells represent bombs and empty cells represent safe cells. Print the array using an asterisk for bombs and a period for safe cells. Then, replace each safe square with the number of neighboring bombs (above, below, left, right, or diagonal) and print the solution.
HS-TEACHER-17464:Array2D gracielaelia$ java Minesweeper 3 3 0.2 . . . . . . * . . 0 0 0 1 1 0 * 1 0
Try to write your code so that you have as few special cases as possible to deal with, by using an (m+2)-by-(n+2) boolean array.
HS-TEACHER-17464:Array2D gracielaelia$ java Minesweeper 3 3 0.3 . . * . . * . . * 0 2 * 0 3 * 0 2 * HS-TEACHER-17464:Array2D gracielaelia$ java Minesweeper 3 3 0.4 . . . * . . . . . 1 1 0 * 1 0 1 1 0 HS-TEACHER-17464:Array2D gracielaelia$ java Minesweeper 3 3 0.5 * * * . * * * . * * * * 4 * * * 4 * HS-TEACHER-17464:Array2D gracielaelia$ java Minesweeper 3 3 0.6 * * * . . * * * * * * * 4 7 * * * * HS-TEACHER-17464:Array2D gracielaelia$ java Minesweeper 3 3 0.7 . * * * * * * . * 3 * * * * * * 5 * HS-TEACHER-17464:Array2D gracielaelia$ java Minesweeper 3 3 0.8 * . * * * . * * * * 4 * * * 4 * * * HS-TEACHER-17464:Array2D gracielaelia$ java Minesweeper 3 3 0.9 * * * * * . * * * * * * * * 5 * * *
Required Submission:
- Copy and paste the program (with the output as a paragraph comment at the end of your program) to the Text entry tab.
-
Submit the file with the ‘”java” extension.
3. Make sure you document code snippets that have a particular purpose!
4. Testing: Have multiple boards with different board sizes and different probabilities. The minimum should be 3 boards.