почему не проходит пред последнее
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];
private void setCellColoredNumber(int x, int y, int value){
String strValue = (value == 0) ? ("") : ("" + value);
Color color = getColorByValue(value);
setCellValueEx(y, x, color,strValue);
}
private Color getColorByValue(int value){
switch(value){
case 2:
return Color.PLUM;
case 4:
return Color.SLATEBLUE;
case 8:
return Color.DODGERBLUE;
case 16:
return Color.DARKTURQUOISE;
case 32:
return Color.MEDIUMSEAGREEN;
case 64:
return Color.LIMEGREEN;
case 128:
return Color.DARKORANGE;
case 256:
return Color.SALMON;
case 512:
return Color.ORANGERED;
case 1024:
return Color.DEEPPINK;
case 2048:
return Color.MEDIUMVIOLETRED;
}
return null;
}
@Override
public void initialize() {
setScreenSize(SIDE, SIDE);
createGame();
drawScene();
}
private void createGame() {
createNewNumber();
createNewNumber();
}
private void createNewNumber() {
boolean isCreated = false;
do {
int x = getRandomNumber(SIDE);
int y = getRandomNumber(SIDE);
if (gameField[y][x] == 0) {
gameField[y][x] = getRandomNumber(10) < 9 ? 2 : 4;
isCreated = true;
}
}
while (!isCreated);
}
private void drawScene() {
for (int y = 0; y < SIDE; y++) {
for (int x = 0; x < SIDE; x++) {
setCellColoredNumber(x, y, gameField[x][y]);
}
}
}
}
