Debugging
Debugging
1. Snake
2. Cell
3. Board
4. Game
import java.util.LinkedList;
public class Snake {
private LinkedList<Cell> snakePartList= new LinkedList<>();
private Cell head;
public Snake(Cell initPos){
head = initPos;
snakePartList.add(head);
head.setCellType(CellType.SNAKE_NODE);
}
head = nextCell;
head.setCellType(CellType.SNAKE_NODE);
snakePartList.addFirst(head);
}
public void
setSnakePartList(LinkedList<Cell> snakePartList){
this.snakePartList = snakePartList;
}
if (snake.checkCrash(nextCell)) {
setDirection(DIRECTION_NONE);
gameOver = true;
}
else {
snake.move(nextCell);
if (nextCell.getCellType()== CellType.FOOD) {
snake.grow();
board.generateFood();
}
}
}
}
}
if (direction == DIRECTION_RIGHT) {
col++;
}
else if (direction == DIRECTION_LEFT) {
col--;
}
else if (direction == DIRECTION_UP) {
row--;
}
else if (direction == DIRECTION_DOWN) {
row++;
}
return nextCell;
}