Created
October 24, 2017 16:22
-
-
Save lubaochuan/40223d4a5bfa616fd4b8ba9cce7431df to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public Maze(String fileName) throws FileNotFoundException{ | |
Scanner scan = new Scanner(new File(fileName)); | |
cols = Integer.parseInt(scan.next()); | |
rows = Integer.parseInt(scan.next()); | |
grid = new Square[rows][cols]; | |
// remove line break; | |
scan.nextLine(); | |
// read maze configuration | |
for(int i=0; i<rows; i++){ | |
String row = scan.nextLine(); | |
for(int j=0; j<cols; j++){ | |
// create a square from the char representation | |
SquareType type = SquareType.fromChar(row.charAt(j)); | |
Square s = new Square(type, i, j); | |
grid[i][j] = s; | |
// remember the square as "start" if it is the starting point | |
if(type == SquareType.START){ | |
start = s; | |
} | |
//System.out.print(row.charAt(j)); | |
} | |
//System.out.println(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment