-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathStone.java
More file actions
42 lines (33 loc) · 1.02 KB
/
Stone.java
File metadata and controls
42 lines (33 loc) · 1.02 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
class Stone {
public static final Stone BLOCKING_STONE = new Stone();
public static final Stone MOVING_STONE = new Stone();
private int destRow;
private int destCol;
private Stone() { }
public Stone(int r, int c) {
destRow = r;
destCol = c;
}
public boolean hasDestination(int row, int col) {
return row == destRow && col == destCol;
}
public boolean equals(Object o) {
if (o == this)
return true;
else if (o != BLOCKING_STONE && o != MOVING_STONE)
return ((Stone)o).destRow == destRow && ((Stone)o).destCol == destCol;
else
return false;
}
public boolean isTempleStone() {
return this != BLOCKING_STONE && this != MOVING_STONE;
}
public boolean isMovingStone() {
return this == MOVING_STONE;
}
public boolean isBlockingStone() {
return this == BLOCKING_STONE;
}
public int getDestRow() { return destRow; }
public int getDestCol() { return destCol; }
}