Everything ok but dont know what is my mistake?
package com.codegym.task.task23.task2312;
import java.util.List;
public class Room {
public static Room game;
private int width, height;
private Snake snake;
private Mouse mouse;
public Room(int width, int height, Snake snake){
this.width = width;
this.height = height;
this.snake = snake;
}
public static void main(String[] args){
Snake snake = new Snake(0, 0);
game = new Room(100, 100, snake);
snake.setDirection(SnakeDirection.DOWN);
game.createMouse();
game.run();
}
public void run(){
}
public void print(){
SnakeSection head = snake.getSections().get(0);
List<SnakeSection> sectionList = snake.getSections();
int[][] matrix = new int[height][width];
matrix[head.getY()][head.getX()] = 2;
matrix[mouse.getY()][mouse.getX()] = 3;
for(int i = 1; i < sectionList.size(); i++){
SnakeSection section = sectionList.get(i);
matrix[section.getY()][section.getX()] = 1;
}
for(int i = 0; i < height; i++){
for(int j = 0; j < width; j++){
if(i == 0 || j == 0 || i == height - 1|| j == width -1)System.out.print(".");
else if(matrix[i][j] == 1) System.out.print("x");
else if(matrix[i][j] == 2) System.out.print("X");
else if(matrix[i][j] == 3) System.out.print("^");
else System.out.print(" ");
}
System.out.println();
}
}
public void sleep(){
int size = snake.getSections().size();
try{
if(size < 11) Thread.sleep(500);
else if(size < 15) Thread.sleep(300);
else Thread.sleep(200);
}catch (Exception e){
}
}
public void createMouse(){
mouse = new Mouse((int)(Math.random()*width), (int)(Math.random()*height));
}
public void eatMouse(){
createMouse();
}
public int getWidth() {
return width;
}
public void setWidth(int width) {
this.width = width;
}
public int getHeight() {
return height;
}
public void setHeight(int height) {
this.height = height;
}
public Snake getSnake() {
return snake;
}
public void setSnake(Snake snake) {
this.snake = snake;
}
public Mouse getMouse() {
return mouse;
}
public void setMouse(Mouse mouse) {
this.mouse = mouse;
}
}