Не прошло по трем требованиям. Что делать?
package com.javarush.games.minesweeper;
import com.javarush.engine.cell.Color;
import com.javarush.engine.cell.Game;
import java.util.ArrayList;
import java.util.List;
public class MinesweeperGame extends Game {
private static final int SIDE = 10;
private GameObject[][] gameField = new GameObject[SIDE][SIDE];
private int countMinesOnField;
private static final String MINE = "\uD83D\uDCA3";
public boolean isOpen = false;
@Override
public void initialize() {
setScreenSize(SIDE, SIDE);
createGame();
}
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, isOpen);
setCellColor(x, y, Color.GREEN);
}
}
countMineNeighbors();
}
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(){
List<GameObject> list=new ArrayList<>();
for(int x=0;x<SIDE;x++){
for(int y=0;y<SIDE;y++){
if(gameField[y][x].isMine==false){
list=getNeighbors(gameField[y][x]);
for(int i=0;i<list.size();i++){
if(list.get(i).isMine){
gameField[y][x].countMineNeighbors++;
}
}
}
}
}
}
private void openTile(int x, int y){
gameField[y][x].isOpen = true;
if(gameField[x][y].isMine){
setCellValue(x, y, MINE);
setCellColor(x, y, Color.ORANGE);
}
else {
setCellNumber(x, y, gameField[y][x].countMineNeighbors);
setCellColor(x, y, Color.GREEN);
}
}
public void onMouseLeftClick(int x, int y){
openTile(x, y);
}
}