Write a recursive method that counts the number of mines on a grid. A mine is defined as a contiguous collection of X’s (connected horizontally and vertically). In java language
Input
Max dimensions of the array
Distribution of mines on the array
Output
The number of mines and the layout of the grid showing the locations of the mines.
Requirements checklist:
❑ Documented source code (include any assumptions you make)
Input File (in.txt)
The format of the input file is as follows: First line is the dimensions of the grid.. Then the grid containing 1s for the creatures and 0s for the spaces. The file terminates by 0 0.
5 5
…..
.XXX.
…..
…..
…..
5 5
….X
.XXX.
X….
…..
…..
0 0
Output File (out.txt)
Experiment # 1
Number of Mines: 1
0 0 0 0 0
0 1 1 1 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
Experiment #2
Number of Mines: 3
0 0 0 0 1
0 2 2 2 0
3 0 0 0 0
0 0 0 0 0
0 0 0 0 0
Marking Scheme
Out of
Grade
Comments
Documentation
3
Meaningful variable names
2
Correct input format
2
Correct output format
2
Modularity
4
Tested
12
Total
25