Currently making a minesweeper game and stuck on being able to loop through the 8 surrounding cells to find the number of surrounding bombs. I have a helper method that I believe works fine that is used to check if the cell (passed by numberOfAdjacentBombs) contains a bomb. How do I go about creating a nested for loop that will loop through each surrounding cell? e.g (row-1, col-1), (row-1, col), (row-1, col+1).
Any help or hints is appreciated, thanks! :-)
private int numberOfAdjacentBombs(int row, int col){
int count = 0;
//nested for loop
count += getIfBomb(int, int)
}
The helper method checks if the cell contains a bomb and returns 1 if it does, 0 if it doesn't.
private in getIfBomb(int row, int col){
if(cells[row][col].getHasBomb() == true){
return 1;
}else{
return 0;
}
}