-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPiece.java
More file actions
42 lines (32 loc) · 997 Bytes
/
Piece.java
File metadata and controls
42 lines (32 loc) · 997 Bytes
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
public abstract class Piece {
private String color;
private int row;
private int col;
public Piece(String color, int row, int col) {
this.color = color;
this.row = row;
this.col = col;
}
public String getColor() {
return color;
}
public int getRow() {
return row;
}
public int getCol() {
return col;
}
public void setPosition(int row, int col) {
this.row = row;
this.col = col;
}
public boolean isWithinBounds(int row, int col) {
return row >= 0 && row < 8 && col >= 0 && col < 8;
}
public boolean isAllyPiece(int row, int col, Piece[][] board) {
return board[row][col] != null && board[row][col].getColor().equals(this.color);
}
public abstract boolean isValidMove(int destRow, int destCol, Piece[][] board);
public abstract String getImagePath();
public abstract String getType();
}