Can anyone help me out here? i can't see the problem
package com.codegym.games.minesweeper;
import com.codegym.engine.cell.Color;
import com.codegym.engine.cell.Game;
import java.util.ArrayList;
import java.util.List;
public class MinesweeperGame extends Game {
private static final int SIDE = 9;
private GameObject[][] gameField = new GameObject[SIDE][SIDE];
private int countMinesOnField;
private static final String MINE = "\uD83D\uDCA3";
private static final String FLAG = "\uD83D\uDEA9";
private int countFlags;
private boolean isGameStopped;
private int countClosedTiles = SIDE*SIDE;
@Override
public void initialize() {
setScreenSize(SIDE, SIDE);
createGame();
}
public void onMouseLeftClick(int x, int y){
openTile(x,y);
}
public void onMouseRightClick(int x, int y){
markTile(x,y);
}
private void createGame() {
for (int y = 0; y < SIDE; y++) {
for (int x = 0; x < SIDE; x++) {
boolean isMine = getRandomNumber(10) < 1;
if (isMine) {
countMinesOnField++;
}
gameField[y][x] = new GameObject(x, y, isMine);
setCellColor(x, y, Color.ORANGE);
}
}
countMineNeighbors();
countFlags = countMinesOnField;
isGameStopped = false;
}
private List<GameObject> getNeighbors(GameObject gameObject) {
List<GameObject> result = new ArrayList<>();
for (int y = gameObject.y - 1; y <= gameObject.y + 1; y++) {
for (int x = gameObject.x - 1; x <= gameObject.x + 1; x++) {
if (y < 0 || y >= SIDE) {
continue;
}
if (x < 0 || x >= SIDE) {
continue;
}
if (gameField[y][x] == gameObject) {
continue;
}
result.add(gameField[y][x]);
}
}
return result;
}
private void countMineNeighbors(){
for (int y = 0; y < SIDE; y++) {
for (int x = 0; x < SIDE; x++) {
if(gameField[y][x].isMine == false){
for(int z = 0; z<getNeighbors(gameField[y][x]).size();z++){
if(getNeighbors(gameField[y][x]).get(z).isMine == true)
gameField[y][x].countMineNeighbors++;
}
}
}
}
}
private void openTile(int x, int y){
GameObject one = gameField[y][x];
if(one.isOpen||one.isFlag||isGameStopped){
return;
}
one.isOpen = true;
countClosedTiles--;
setCellColor(one.x,one.y,Color.GREEN);
if(one.isMine){
setCellValueEx(one.x,one.y,Color.RED,MINE);
gameOver();
}
else {
if(one.countMineNeighbors == 0){
setCellValue(one.x,one.y,"");
ArrayList<GameObject> neighbor = new ArrayList<GameObject>(getNeighbors(one));
for (GameObject neighbors : neighbor){
if(!neighbors.isOpen)
openTile(neighbors.x,neighbors.y);
}
}
else{
setCellNumber(one.x,one.y,one.countMineNeighbors);
}}
if(countClosedTiles==countMinesOnField){
win();
}
}
private void markTile(int x, int y){
GameObject two = gameField[y][x];
if(two.isOpen||(countFlags == 0 && two.isFlag == false)||isGameStopped){
return;
}
if(!two.isFlag){
two.isFlag = true;
countFlags--;
setCellValue(two.x,two.y,FLAG);
setCellColor(two.x,two.y,Color.YELLOW);
}
else{
two.isFlag = false;
countFlags++;
setCellValue(two.x,two.y,"");
setCellColor(two.x,two.y,Color.ORANGE);
}
}
private void gameOver(){
isGameStopped = true;
showMessageDialog(Color.WHITE, "Game Over", Color.BLACK, 50);
}
private void win(){
isGameStopped = true;
showMessageDialog(Color.WHITE, "YOU WIN", Color.BLUE, 50);
}
}