Где здесь ошибка ?
package com.javarush.games.minesweeper;
import com.javarush.engine.cell.*;
import java.util.ArrayList;
import java.util.List;
public class MinesweeperGame extends Game {
private static final int SIDE = 9;
private static final String MINE = "\uD83D\uDCA3";
private GameObject[][] gameField = new GameObject[SIDE][SIDE];
private int countMinesOnField;
public boolean isOpen;
@Override
public void initialize() {
setScreenSize(SIDE, SIDE);
createGame();
}
private void createGame(){
for (int x=0; x<SIDE;x++) {
for (int y = 0; y < SIDE; y++) {
if (getRandomNumber(10) < 0.1) {
gameField[y][x] = new GameObject(x, y, true);
setCellColor(x, y, Color.PLUM);
countMinesOnField++;
}else {
gameField[y][x] = new GameObject(x, y, false);
setCellColor(x, y, Color.PLUM);
}
}
}
countMineNeighbors();
}
private List<GameObject> getNeighbors(GameObject gameObject) {
List list=new ArrayList<GameObject>();
int x = gameObject.x;
int y = gameObject.y;
for (int i=y-1; i<=y+1; i++)
for (int j=x-1; j<=x+1; j++){
if ( (j!=x || i!=y)&&(j>=0 && i>=0 && j<SIDE && i<SIDE) )
list.add(gameField[i][j]);
}
return list;
}
private void countMineNeighbors() {
List<GameObject>list2 = new ArrayList<>();
for(int x = 0; x<SIDE; x++){
for(int y = 0; y<SIDE; y++){
if(!gameField[y][x].isMine) {
list2=getNeighbors(gameField[y][x]);
for (int i = 0; i<list2.size(); i++) {
if (list2.get(i).isMine)
gameField[y][x].countMineNeighbors++;
}
}
}
}
}
private void openTile(int x, int y) {
gameField[x][y].isOpen = true;
setCellColor(x, y, Color.BLACK);
if (gameField[x][y].isMine) {
setCellValue(x, y, MINE);
}
else {
setCellNumber(x, y, gameField[x][y].countMineNeighbors);
}
}
@Override
public void onMouseLeftClick(int x,int y){
openTile(x,y);
}
}