Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 9th, 2012  |  syntax: Java  |  size: 1.37 KB  |  hits: 18  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
This paste has a previous version, view the difference. Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1.         public void searchMaze(int r, int c) {
  2.                                
  3.                 if(mazeArray[currentRow][currentColumn] == exit) {
  4.                         System.out.printf("The explorer has left the building!\n");
  5.                         System.exit(0);
  6.                 }
  7.                 else if(mazeArray[currentRow - 1][currentColumn] == space || mazeArray[currentRow - 1][currentColumn] == visited) {
  8.                         mazeArray[currentRow][currentColumn] = visited;
  9.                         mazeArray[currentRow - 1][currentColumn] = explorer;
  10.                         currentRow -= 1;
  11.                         searchMaze(currentRow, currentColumn);
  12.                 }
  13.                
  14.                 else if(mazeArray[currentRow][currentColumn + 1] == space || mazeArray[currentRow][currentColumn + 1] == visited) {
  15.                         mazeArray[currentRow][currentColumn] = visited;
  16.                         mazeArray[currentRow][currentColumn + 1] = explorer;
  17.                         currentColumn += 1;
  18.                         searchMaze(currentRow, currentColumn);
  19.                 }
  20.  
  21.                 else if(mazeArray[currentRow + 1][currentColumn] == space || mazeArray[currentRow + 1][currentColumn] == visited) {
  22.                         mazeArray[currentRow][currentColumn] = visited;
  23.                         mazeArray[currentRow + 1][currentColumn] = explorer;
  24.                         currentRow += 1;
  25.                         searchMaze(currentRow, currentColumn);
  26.                 }
  27.                
  28.                 else if(mazeArray[currentRow][currentColumn - 1] == space || mazeArray[currentRow][currentColumn - 1] == visited) {
  29.                         mazeArray[currentRow][currentColumn] = visited;
  30.                         mazeArray[currentRow][currentColumn - 1] = explorer;
  31.                         currentColumn -= 1;
  32.                         searchMaze(currentRow, currentColumn);
  33.                 }
  34.                
  35.         }