-
Notifications
You must be signed in to change notification settings - Fork 0
/
Piece.java
56 lines (48 loc) · 1.04 KB
/
Piece.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
47
48
49
50
51
52
53
54
55
56
import java.awt.Color;
import javax.swing.ImageIcon;
/** Represents a chess piece. */
public abstract class Piece {
/** Represents name of the chess piece. */
private Name name;
/** Represents the assigned color (e.g., WHITE or BLACK). */
private Color color;
/**
* Initializes a chess piece.
*
* @param name is a chess piece name
* @param color is a chess piece color
* @param icon is a chess piece icon
*/
public Piece(Name name, Color color) {
this.name = name;
this.color = color;
}
/**
* Gets the piece name.
*
* @return name of piece
*/
public Name getName() {
return this.name;
}
/**
* Gets the piece color.
*
* @return color of piece
*/
public Color getColor() {
return this.color;
}
/**
* Gets the piece icon.
*
* @return icon of piece
*/
abstract ImageIcon getIcon();
/** Checks if the piece can move to the position.
*
* @param position is a tile coordinate.
* @return true if valid move, else false.
*/
abstract boolean checkMove(Position start, Position end);
}