-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathPiece.java
More file actions
99 lines (79 loc) · 2.01 KB
/
Piece.java
File metadata and controls
99 lines (79 loc) · 2.01 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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
import javafx.scene.image.Image;
//class declaration - abstract because we will not want to create a Piece object but we would
//like to specify the private fields that all pieces should have in addition to their behaviours
public abstract class Piece {
//piece can be either white (1) or black (2)
private int type;
private String name;
private String imgname;
private int i;
private int j;
private Piece[][] newboard;
private boolean firstmove;
public Image image(){
return image();
}
public int icoord(){
// Bounds correction
if(i > 8){
return 7;}
if(i < 0){
return 0;}
else{return i;}
}
public int jcoord(){
// Bounds correction
if(j > 8){
return 7;}
if(i < 0){
return 0;}
else{return j;}
}
@Override
public String toString(){
return name;
}
public String imagefilename(){
return imgname;
}
public Piece(int type){
this.type=type;
}
public boolean firstmove(){
return firstmove;
}
public int type(){
if(type == 1){
return 1;
}
if(type == 2){
return 2;
}
else return 0;
}
// Abstract methods for piece class children to implement
public Piece[][] movepawn(Piece selectedpiece, Piece targetpiece, Piece[][] boardstate) {
// TODO Auto-generated method stub
return newboard;
}
public Piece[][] movebishop(Piece selectedpiece, Piece targetpiece, Piece[][] boardstate) {
// TODO Auto-generated method stub
return newboard;
}
public Piece[][] movequeen(Piece selectedpiece, Piece targetpiece, Piece[][] boardstate) {
// TODO Auto-generated method stub
return newboard;
}
public Piece[][] moverook(Piece selectedpiece, Piece targetpiece, Piece[][] boardstate) {
// TODO Auto-generated method stub
return newboard;
}
public Piece[][] moveking(Piece selectedpiece, Piece targetpiece, Piece[][] boardstate) {
// TODO Auto-generated method stub
return newboard;
}
public Piece[][] moveknight(Piece selectedpiece, Piece targetpiece, Piece[][] boardstate) {
// TODO Auto-generated method stub
return newboard;
}
}