-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathPiece.java
More file actions
71 lines (53 loc) · 1.1 KB
/
Piece.java
File metadata and controls
71 lines (53 loc) · 1.1 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
63
64
65
66
67
68
69
70
71
//Brian Pomerantz
import java.util.*;
abstract class Piece {
private byte value, rank, file;
private char symbol;
private boolean side;
protected ArrayList<Piece> moves, attack;//, defend;
public Piece(boolean si, char sy, byte v, byte r, byte f) {
side = si;
symbol = sy;
value = v;
rank = r;
file = f;
moves = new ArrayList<Piece>();
attack = new ArrayList<Piece>();
//defend = new ArrayList<Piece>();
}
protected byte getRank() {
return rank;
}
protected byte getFile() {
return file;
}
protected void setPosition(byte r, byte f) {
rank = r;
file = f;
}
protected byte getValue() {
return value;
}
protected void setValue(byte v) {
value = v;
}
public char getSymbol() {
return symbol;
}
public String toString() {
if (this instanceof Null) {
return " ";
}
if (side) {
return "W" + symbol;
}
return "B" + symbol;
}
public boolean getSide() {
return side;
}
abstract void update(Board b);
abstract ArrayList<Piece> getMoves();
abstract ArrayList<Piece> getAttack();
//abstract ArrayList<Piece> getDefend();
}