Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- BufferedReader txt = new BufferedReader( new FileReader( file ) );
- String line;
- maze = new Cell[size][size];
- int x;
- int y;
- String left = "left";
- String right = "right";
- String top = "top";
- String bottom = "bottom";
- while( ( line = txt.readLine() ) != null ){
- StringTokenizer t = new StringTokenizer(line, " ");
- x = Integer.parseInt(t.nextToken());
- y = Integer.parseInt(t.nextToken());
- if ( t.hasMoreTokens()){
- String operation = t.nextToken();
- switch( operation ){
- case "PD":
- maze[x][y] = new Cell();
- maze[x][y].makeWall(top);
- maze[x][y].makeWall(left);
- if ( x != 0 && y != 0){
- maze[x][y-1].makeWall(bottom);
- maze[x-1][y].makeWall(right);
- }
- if ( x == 0 && y != 0 ){
- maze[x][y-1].makeWall(bottom);
- }
- if ( x != 0 && y == 0 ){
- maze[x-1][y].makeWall(right);
- }
- break;
- case "P":
- maze[x][y] = new Cell();
- maze[x][y].makeWall(top);
- if ( x != 0 && y != 0){
- maze[x][y-1].makeWall(bottom);
- }
- if ( x == 0 && y != 0 ){
- maze[x][y-1].makeWall(bottom);
- }
- break;
- case "D":
- maze[x][y] = new Cell();
- maze[x][y].makeWall(left);
- if ( x != 0 && y != 0){
- maze[x-1][y].makeWall(right);
- }
- if ( x != 0 && y == 0 ){
- maze[x-1][y].makeWall(right);
- }
- break;
- }
- }
- else {
- maze[x][y] = new Cell();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement