-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMaze.java
More file actions
62 lines (52 loc) · 1.19 KB
/
Maze.java
File metadata and controls
62 lines (52 loc) · 1.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
public class Maze {
private char[][] mazeData;
private MazeLocation start;
private MazeLocation finish;
public Maze(char[][] textMaze, MazeLocation start, MazeLocation finish) {
mazeData = textMaze;
this.start = start;
this.finish = finish;
}
public MazeLocation getStart() {
return start;
}
public MazeLocation getFinish() {
return finish;
}
public char getChar(int row, int col) {
return mazeData[row][col];
}
public void setChar(int row, int col, char val) {
mazeData[row][col] = val;
}
public int getSize() {
if (mazeData.length > 0) {
return mazeData.length * mazeData[0].length;
}
return 0;
}
public int getRows() {
return mazeData.length;
}
public int getCols() {
if (mazeData.length > 0) {
return mazeData[0].length;
}
return 0;
}
public String toString() {
String details = " ";
for (int i = 0; i < mazeData[0].length; i++) {
details += i%10;
}
details += "\n";
for (int i = 0; i < mazeData.length; i++) {
details += i%10;
for (int j = 0; j < mazeData[i].length; j++) {
details += mazeData[i][j];
}
details +="\n";
}
return details;
}
}