-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSquare.java
More file actions
55 lines (46 loc) · 1.15 KB
/
Square.java
File metadata and controls
55 lines (46 loc) · 1.15 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
public class Square {
private int row;
private int col;
private int val;
private int vis;
public Square(int row, int col, int val) {
this.row = row;
this.col = col;
this.val = val;
//Key: Vis = 0: not visited Vis = 1: Currently on worklist Vis = 2: Removed permanently from worklist
this.vis = 0;
}
public int getRow() {
return this.row;
}
public int getCol() {
return this.col;
}
public int getVal() {
return this.val;
}
public int getVis() {
return this.vis;
}
public boolean isEqual(Square s) {
return this.row == s.getRow() && this.col == s.getCol();
}
public void work() {
this.vis = 1;
}
public void onPath() {
this.vis = 2;
}
public void reset() {
this.vis = 0;
}
public String toString() {
switch(val) {
case 0: if(vis == 0) {return "o";} else if(vis == 1) {return "x";} else {return ".";}
case 1: return "#";
case 2: return "S";
case 3: return "E";
}
return null;
}
}