https://codegym.cc/tasks/com.codegym.games.minesweeper.part06
Should I implemet getNeighbors() method myself?
Compiler can not find this method.
com/codegym/games/minesweeper/part06/MinesweeperGame.java:35: error: cannot find symbol
symbol: method getNeighbors(com.codegym.games.minesweeper.part06.GameObject)
location: class com.codegym.games.minesweeper.part06.MinesweeperGame
package com.codegym.games.minesweeper;
import com.codegym.engine.cell.*;
public class MinesweeperGame extends Game {
private static final int SIDE = 9;
private int countMinesOnField;
private GameObject[][] gameField = new GameObject[SIDE][SIDE];
public void initialize() {
setScreenSize(SIDE, SIDE);
createGame();
}
private void createGame(){
for(int i=0; i<SIDE; i++){
for(int j=0; j<SIDE; j++){
boolean isMine=false;
if (j==getRandomNumber(10)){
isMine=true;
countMinesOnField++;
}
gameField[i][j] = new GameObject(j,i,isMine);
setCellColor(i,j, Color.RED);
}
}
countMineNeighbors();
}
private void countMineNeighbors(){
for(int i=0; i<SIDE; i++){
for(int j=0; j<SIDE; j++){
if (!(gameField[i][j].isMine)){
//getNeighbors(gameField[i][j]);
gameField[i][j].countMineNeighbors = getNeighbors(gameField[i][j]);
}
gameField[i][j].countMineNeighbors=0;
return;
}
}
return;
}
}