-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGamePiece.java
85 lines (69 loc) · 1.58 KB
/
GamePiece.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
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
import java.awt.Color;
import java.awt.Graphics;
import javax.swing.JButton;
import javax.swing.JComponent;
@SuppressWarnings("serial")
public class GamePiece extends JComponent {
private boolean isPreview;
private boolean isVisible;
private boolean isBlack;
private int rownum;
private int colnum;
public BoardSquare location; //the square where this piece is located
public GamePiece(int y, int x, boolean b) {
isVisible = false;
isBlack = b;
rownum = y;
colnum = x;
}
/*
//overloads Piece construction for purposes of preview feature
public GamePiece(int y, int x, boolean b, boolean isprev) {
isVisible = true;
isBlack = b;
rownum = y;
colnum = x;
isPreview = isprev;
}
*/
public boolean getVisibility() {
return isVisible;
}
public void setVisibility(boolean b) {
isVisible = b;
}
public void setVisible() {
isVisible = true;
}
public void setBoardLocation(BoardSquare b) {
location = b;
}
public boolean getColorBoolean() {
return isBlack;
}
public Color getColor() {
if (isBlack)
return Color.BLACK;
else
return Color.WHITE;
}
public void setColor(boolean b) {
isBlack = b;
}
public int getRowNum() {
return rownum;
}
public int getColNum() {
return colnum;
}
public void draw(Graphics gc) {
if (!isPreview) {
gc.setColor(getColor());
gc.fillOval(rownum, colnum, BoardSquare.SQUARE_DIM, BoardSquare.SQUARE_DIM);
} else {
System.out.println("drawPreview is entered");
gc.setColor(Color.RED);
gc.drawOval(rownum, colnum, BoardSquare.SQUARE_DIM, BoardSquare.SQUARE_DIM);
}
}
}