I can't understand why it's not getting verified
Please help me!!!!!
package com.codegym.games.snake;
import com.codegym.engine.cell.*;
public class SnakeGame extends Game{
public static final int WIDTH = 15;
public static final int HEIGHT = 15;
private Snake snake;
private int turnDelay;
private Apple apple;
public void initialize(){
setScreenSize(WIDTH,HEIGHT);
createGame();
}
private void createNewApple(){
int x = getRandomNumber(WIDTH);
int y = getRandomNumber(HEIGHT);
apple = new Apple(x,y);
}
public void onKeyPress(Key k){
if(k == Key.LEFT){
snake.setDirection(Direction.LEFT);
}
else if(k == Key.RIGHT ){
//if(snake.getDirection() != k)
snake.setDirection(Direction.RIGHT);
}
else if(k == Key.UP ){
//if(snake.getDirection() != k)
snake.setDirection(Direction.UP);
}
else if(k == Key.DOWN ){
//if(snake.getDirection() != k)
snake.setDirection(Direction.DOWN);
}
// else{
// snake.setDirection(snake.getDirection());
// }
}
public void onTurn(int a){
//snake.move();
snake.move(apple);
if(apple.isAlive==false){
createNewApple();
}
drawScene();
}
private void createGame(){
snake = new Snake(WIDTH/2,HEIGHT/2);
createNewApple();
drawScene();
//Apple a = new Apple(7,7);
//a.draw(this);
turnDelay = 300;
setTurnTimer(turnDelay);
}
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);
}
}