it is not compiling
package com.codegym.games.minesweeper;
import com.codegym.engine.cell.*;
public class MinesweeperGame extends Game {
private static final String MINE = "\uD83D\uDCA3";
private static final String FLAG = "\uD83D\uDEA9";
private static final int SIDE = 9;
private static final int TEXTSIZE = 22;
private static final int TILES = SIDE * SIDE;
private int countMinesOnField = 0;
private int countFlags;
private int countClosedTiles = TILES;
private boolean isGameStopped;
private GameObject[][] gameField = new GameObject[SIDE][SIDE];
private void createGame() {
for (int x = 0; x < SIDE; ++x) {
for (int y = 0; y < SIDE; ++y) {
boolean isMine = getRandomNumber(10) < 1;
if (isMine) {
++countMinesOnField;
}
gameField[y][x] = new GameObject(x, y, isMine);
setCellColor(x, y, Color.ORANGE);
isGameStopped = false;
}
}
countMineNeighbors();
countFlags = countMinesOnField;
}
private void countMineNeighbors() {
for (int x = 0; x < SIDE; ++x) {
for (int y = 0; y < SIDE; ++y) {
if (gameField[y][x].isMine) {
continue;
}
for (GameObject item: getNeighbors(gameField[y][x])) {
if (item.isMine) {
gameField[y][x].countMineNeighbors++;
}
}
}
}
}
private void openTile(int x, int y) {
// 3. The openTile(int, int) method must not do anything if the game is stopped (isGameStopped == true).
if (isGameStopped) {
return;
}
// 2. The openTile(int, int) method must not do anything if the element is flagged.
if (gameField[y][x].isFlag) {
return;
}
// 1. The openTile(int, int) method must not do anything if the element is already revealed.
if (gameField[y][x].isOpen) {
return;
}
if (gameField[y][x].isMine) {
setCellValueEx(x, y, Color.RED, MINE);
gameOver();
}
// The openTile(int, int) method must draw the number of adjacent mines
// if the gameObject at the passed coordinates is not a mine.
else {
gameField[y][x].isOpen = true;
--countClosedTiles;
if (gameField[y][x].countMineNeighbors != 0) {
setCellNumber(x, y, gameField[y][x].countMineNeighbors);
}
else {
setCellValue(x, y, "");
for (GameObject neighbor : getNeighbors(gameField[y][x])) {
if (!gameField[neighbor.y][neighbor.x].isOpen) {
openTile(neighbor.x, neighbor.y);
}
}
}
setCellColor(x, y, Color.GREEN);
}
// 6. The openTile(int, int) method must call the win() method if the number of hidden cells
// is equal to the number of mines on the field and the last revealed cell is not a mine.
if (countClosedTiles == countMinesOnField) {
win();
}
}
private void markTile(int x, int y) {
// private int countMinesOnField = 0;
// private int countFlags;
//2. The markTile(int x, int y) method must not do anything if the element is already revealed
// (isOpen == true).
if (isGameStopped) {
return;
}
if (gameField[y][x].isOpen) {
return;
}
// 3. The markTile(int, int) method must not do anything if the number of unused flags (countFlags) is zero
// and the current element is not a flag (isFlag = false).
if (!gameField[y][x].isFlag && countFlags == 0) {
return;
}
// 4. The markTile(int, int) method must set the isFlag field to true,
// reduce the number of unused flags by one,
// draw the FLAG symbol on the field if the current element is not a flag
// (use the setCellValue(int, int, String) method), and change the cell background on the field
// (use the setCellColor(int, int, Color) method). For example, to Color.YELLOW.
if (!gameField[y][x].isFlag) {
gameField[y][x].isFlag = true;
setCellValue(x, y, FLAG);
--countFlags;
setCellColor(x, y, Color.YELLOW);
}
// 5. The markTile(int, int) method must set the isFlag field to false,
// increase the number of unused flags by one,
// draw an empty cell on the field if the current element is a flag
// (use the setCellValue(int, int, String) method), and change the cell background on the field
// (use the setCellColor(int, int, Color) method).
else {
gameField[y][x].isFlag = false;
++countFlags;
setCellValue(x, y, "");
setCellColor(x, y, Color.ORANGE);
}
}
private void win() {
// 4. The win() method must set the isGameStopped variable to true.
isGameStopped = true;
// 5. The win() method must call the showMessageDialog(Color, String, Color, int) method.
showMessageDialog(Color.GREEN, "You won!", Color.BLACK, TEXTSIZE);
}
private void gameOver() {
isGameStopped = true;
showMessageDialog(Color.BLACK, "GAME OVER", Color.RED, TEXTSIZE);
}
private GameObject[] getNeighbors(GameObject gameObject) {
int minX = Math.max(0, gameObject.x - 1);
int maxX = Math.min(SIDE - 1, gameObject.x + 1);
int minY = Math.max(0, gameObject.y - 1);
int maxY = Math.min(SIDE - 1, gameObject.y + 1);
GameObject[] neighbors = new GameObject[(maxX - minX + 1) * (maxY - minY + 1) - 1];
int index = 0;
for (int x = minX; x <= maxX; ++x) {
for (int y = minY; y <= maxY; ++y) {
if (x == gameObject.x && y == gameObject.y) {
continue;
}
neighbors[index] = gameField[y][x];
++index;
}
}
return neighbors;
}
@Override
public void initialize() {
setScreenSize(SIDE, SIDE);
createGame();
}
@Override
public void onMouseLeftClick(int x, int y) {
openTile(x, y);
}
// 6. The MinesweeperGame class must override the Game parent class's onMouseRightClick(int, int) method.
// 7. The onMouseRightClick(int, int) method must call the markTile(int, int) method.
@Override
public void onMouseRightClick(int x, int y) {
markTile(x, y);
}
}