I have spent 4 days with this one issue and have search countless of possible solutions and now I am pulling out my hair. I am trying to get a minesweeper 2d character array game to first count the mines surrounding(basically the 8 blocks surrounding the mine) a mine then convert the characters surrounding the mines to integers. I would greatly appreciate if anyone could help. This is homework that is due tomorrow. I feel like such a dummy, but I have literally spent sleepless nights working on this one issue. :'( Someone please help
example m is mine
here is part of a void method that is suppose to check the areas around a mine and convert them to numbers calling the adjacentMines method
for(this.rows = 0; rows < board.length; rows++) {
for(this.cols = 0; cols < board[rows].length; cols++) {
for(int i = -1; i <= 1; i++) {
for(int j = -1; j <= 1; j++) {
if(i == 0 && j == 0) {
continue;
}
else
if(inBounds(rows + i, cols + j))
board[i][j]=(char)(48+adjacentMines(i,j));
}
}
}
}
}
When I want something like this
I want it to look like this when I select a cordinate, where x is the selected coordinate and not a mine, so I want to the output like this. The array above is just the current state, I want numbers to replace the e in the output
| 0 | 1 | 0 |
| 0 | x | 1 |
| 0 | 0 | 0 |
There’s an empty statement:
Notice the semi-colon at the end.
Also, in the latter snippet of code, the loops for
iandjare redundant. You should get rid of them, and you shouldn’t be counting mines for occupied cells.