Problems with move method and draw scene method.
Now you need to combine the work of the createNewHead() and removeTail() methods. The move() method is a good place to do this.
Add a check to see whether the snake has gone beyond the boundaries of the playing field. If the new head is beyond the boundaries of the playing field, set the snake's state to dead.
After moving the snake, you need to clear from the playing field any snake segments that no longer exist. To do this, the drawScene() method should not only change the color of cells, but also assign an empty string to those cells.
Requirements:
- The createNewHead() method must be called in the Snake class's move() method.
- In the move() method, the result of the call to the createNewHead() method must be added to snakeParts at position 0.
- In the Snake class's move() method, the removeTail() method must be called after the new snake head is created.
- In the move() method, if the createNewHead() method returns an element whose coordinates are outside the playing field, you need to set the isAlive field to false and do nothing else.
- In the SnakeGame class's drawScene() method, you must replace the call to the setCellColor(int, int, Color) method with a call to the setCellValueEx(int, int, Color, String) method with arguments (x, y, <color> (for example, Color.DARKSEAGREEN), "").
Bud1% @ @ @ @E%DSDB` @ @ @