Draw Required Balls on Maze

Learn to draw the current, end position balls and add methods for drawing the path taken.

Adding cell methods for drawing balls

Next, look at how to solve the puzzle. You will mark the end of the puzzle with a red ball and the user’s current position in the puzzle with a green ball.

  1. Add private Boolean instance variables called current and end, each initialized to false.
    ...
  
  private boolean[] wall = {true, true, true, true};
  
 private boolean current = false;
	private boolean end = false;
  
    ...

MazeGenerator will need a way to make the cell current.

  1. Add a public method called setCurrent(). It should take one parameter, a Boolean called current, and return nothing.
  2. Use this. to set the instance variable current to the current parameter value.
  3. Repaint the cell using JPanel’s repaint() method.
    ...
  
  ______________ setCurrent(_____________) {
    _________.current = __________;
    ____________;
  }
    ...

Get hands-on with 1200+ tech skills courses.