-
Notifications
You must be signed in to change notification settings - Fork 0
/
Queen.java
46 lines (40 loc) · 857 Bytes
/
Queen.java
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
public class Queen extends Bishop {
public Queen(String color) {
super(color, 3);
}
public Queen(String color, int x, int y) {
super(color, x, y);
}
public String getName() {
return "Queen";
}
public String getRep() {
if (color == "white")
return "D";
else
return "d";
}
public void findNextPositions() {
super.findNextPositions();
Position next = currentPosition.top();
while(next.valid()) {
addNextPosition(next);
next = next.top();
}
next = currentPosition.right();
while(next.valid()) {
addNextPosition(next);
next = next.right();
}
next = currentPosition.bottom();
while(next.valid()) {
addNextPosition(next);
next = next.bottom();
}
next = currentPosition.left();
while(next.valid()) {
addNextPosition(next);
next = next.left();
}
}
}