Всем доброго времени суток. Валидатор не хочет принимать мое решение:
if(!apple.isAlive){
score = score + 5;
setScore(score);
turnDelay = turnDelay - 10;
setTurnTimer(turnDelay);
}
Выдает ошибку в последнем пункте(( Подскажите пожалуйста, что я не так делаюpackage com.javarush.games.snake;
import com.javarush.engine.cell.*;
public class SnakeGame extends Game {
public static final int WIDTH = 15;
public static final int HEIGHT = 15;
private int turnDelay;
private Snake snake;
private Apple apple;
private boolean isGameStopped;
private static final int GOAL = 28;
private int score;
@Override
public void initialize(){
setScreenSize(WIDTH, HEIGHT);
createGame();
}
private void createGame(){
score = 0;
turnDelay = 300;
setTurnTimer(turnDelay);
Snake sn = new Snake(WIDTH/2, HEIGHT/2);
snake = sn;
createNewApple();
isGameStopped = false;
setScore(score);
drawScene();
}
private void drawScene(){
for(int i = 0; i < WIDTH; i++){
for(int j = 0; j < HEIGHT; j++){
setCellValueEx(i, j, Color.DARKSEAGREEN, "");
}
}
snake.draw(this);
apple.draw(this);
}
@Override
public void onTurn(int x){
snake.move(apple);
if(!apple.isAlive){
createNewApple();
}
if(!snake.isAlive){
gameOver();
}
if(snake.getLength() > GOAL){
win();
}
if(!apple.isAlive){
score = score + 5;
setScore(score);
turnDelay = turnDelay - 10;
setTurnTimer(turnDelay);
}
drawScene();
}
@Override
public void onKeyPress(Key key){
if(key == key.LEFT){
snake.setDirection(Direction.LEFT);
}
if(key == key.UP){
snake.setDirection(Direction.UP);
}
if(key == key.RIGHT){
snake.setDirection(Direction.RIGHT);
}
if(key == key.DOWN) {
snake.setDirection(Direction.DOWN);
}
if(key == key.SPACE) {
if(isGameStopped){
createGame();
}
}
}
private void createNewApple(){
do {
apple = new Apple(getRandomNumber(WIDTH), getRandomNumber(HEIGHT));
}while(snake.checkCollision(apple));
}
private void gameOver(){
isGameStopped = true;
stopTurnTimer();
showMessageDialog(Color.RED, "Game over", Color.GREEN, 50000);
}
private void win(){
isGameStopped = true;
stopTurnTimer();
showMessageDialog(Color.GREEN, "WIN!", Color.RED, 50000);
}
public void setScore(int score){
this.score = score;
}
}