Не могу понять почему не проходит валидацию, подскажите люди добрые!
package com.javarush.games.game2048;
import com.javarush.engine.cell.*;
public class Game2048 extends Game {
private static final int SIDE = 4;
private int[][] gameField = new int[SIDE][SIDE];
@Override
public void initialize() {
setScreenSize(SIDE,SIDE);
createGame();
drawScene();
}
private void createGame(){
createNewNumber();
createNewNumber();
}
private void drawScene(){
for (int y = 0; y <SIDE ; y++) {
for (int x = 0; x < SIDE; x++) {
setCellColoredNumber(y,x,gameField[y][x]);
}
}
}
private void createNewNumber(){
while (true) {
int x = getRandomNumber(SIDE);
int y = getRandomNumber(SIDE);
if(gameField[y][x]!=0){
continue;
}
else {
int randomNumber = getRandomNumber(10);
if(randomNumber==9){
gameField[y][x] = 4;
break;
}
else {
gameField[y][x] = 2;
break;
}
}
}
}
private void setCellColoredNumber(int x,int y, int value){
if(value == 0){
setCellValueEx(x,y,getColorByValue(value), " ");
}
else setCellValueEx(x,y,getColorByValue(value),value+"");
}
private Color getColorByValue(int value){
switch (value){
case (0):
return Color.GREEN;
case (2):
return Color.BLUE;
case (4):
return Color.YELLOW;
case (8):
return Color.PINK;
case (16):
return Color.GREY;
case (32):
return Color.CORAL;
case (64):
return Color.DARKGREEN;
case (128):
return Color.VIOLET;
case (256):
return Color.WHITE;
case (512):
return Color.ORANGE;
case (1024):
return Color.AQUA;
case (2048):
return Color.OLIVE;
}
return Color.RED;
}
}
