/**
  * Search for the end of the maze using the frontier. Keep going until you find a solution or run
  * out of elements on the frontier.
  */
 private boolean solve() {
   Node current = new Node(startRow, startCol, null);
   placesToGo.add(current);
   while (placesToGo.hasNext()) {
     current = placesToGo.next();
     if (maze[current.getRow()][current.getCol()] == 'E') {
       return true;
     }
     neighbors(current);
     if (animate) {
       wait(100);
       toString();
     }
   }
   return false;
 }
 public boolean neighbors(Node current) {
   try {
     if (maze[current.getRow() + 1][current.getCol()] == ' ') {
       placesToGo.add(new Node(current.getRow() + 1, current.getCol(), current));
     }
     if (maze[current.getRow() - 1][current.getCol()] == ' ') {
       placesToGo.add(new Node(current.getRow() - 1, current.getCol(), current));
     }
     if (maze[current.getRow()][current.getCol() + 1] == ' ') {
       placesToGo.add(new Node(current.getRow(), current.getCol() + 1, current));
     }
     if (maze[current.getRow()][current.getCol() - 1] == ' ') {
       placesToGo.add(new Node(current.getRow(), current.getCol() - 1, current));
     }
     return true;
   } catch (IndexOutOfBoundsException e) {
     return false;
   }
 }