End and Start a New Game

Did the player win the game?

How can you tell if the user solved the puzzle? The puzzle is solved if the ball moves to the cell at endRow and endCol.

At the end of moveBall(), check whether row and col are at endRow and endCol. If they are:

  1. Create a string called message, congratulating the user on solving the maze.
  2. Display message in a message dialog using JOptionPane’s showMessageDialog() method.
    ...
 
  private void moveBall(int direction) {
 
            ...
 
          moveTo(row, col+1, Cell.RIGHT, Cell.LEFT);
        }
      }
      break;
    }
    
    // puzzle solved?
    if (_____________ && _______________) {
      String message = "__________________________";
      JOptionPane.showMessageDialog(_______________);
    }
  }
    ...

Get hands-on with 1200+ tech skills courses.