-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCard.java
More file actions
170 lines (135 loc) · 2.73 KB
/
Card.java
File metadata and controls
170 lines (135 loc) · 2.73 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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
/*
Name: Dylan Snelgrove
Date: January 12, 2018
Card
- contains all the data to draw the card
- has contructors and a draw to draw it all
*/
import java.awt.*;
import java.applet.*;
import java.awt.image.*;
public class Card extends ShapeClass
{
//instantiated data
private int faceValue; //1 - 13
private int suit; //Diamond, Heart, Club, Spade
private boolean isShowing;
private int size; //1-4, 1 = small, 4 = extra large
//constructors
public Card ()
{
faceValue = 1;
suit = 1;
super.setCenterX (200);
super.setCenterY (200);
super.setWidth ((int) (80 * 0.7));
super.setHeight (80);
super.setColor (Color.black);
isShowing = true;
size = 2;
}
public Card (int pFaceValue, int pSuit)
{
faceValue = 1;
suit = 1;
super.setCenterX (200);
super.setCenterY (200);
super.setWidth ((int) (80 * 0.7));
super.setHeight (80);
size = 2;
super.setColor (Color.black);
isShowing = true;
if (pFaceValue >= 1 && pFaceValue <= 13)
{
faceValue = pFaceValue;
}
if (pSuit >= 1 && pSuit <= 4)
{
suit = pSuit;
}
}
//communicators
public void setSize (int ipSize)
{
if (ipSize >= 1 && ipSize <= 4)
{
size = ipSize;
}
if (ipSize == 1)
{
super.setWidth ((int) (60 * 0.7));
super.setHeight (60);
}
else if (ipSize == 2)
{
super.setWidth ((int) (80 * 0.7));
super.setHeight (80);
}
else if (ipSize == 3)
{
super.setWidth ((int) (100 * 0.7));
super.setHeight (100);
}
else if (ipSize == 4)
{
super.setWidth ((int) (120 * 0.7));
super.setHeight (120);
}
}
public void setFaceValue (int ipFaceValue)
{
if (ipFaceValue >= 1 && ipFaceValue <= 13)
{
faceValue = ipFaceValue;
}
}
public void setSuit (int ipSuit)
{
if (ipSuit >= 1 && ipSuit <= 4)
{
suit = ipSuit;
}
}
public void setIsShowing (boolean ipIsShowing)
{
isShowing = ipIsShowing;
}
int getSize ()
{
return size;
}
int getSuit ()
{
return suit;
}
int getFaceValue ()
{
return faceValue;
}
boolean getIsShowing ()
{
return isShowing;
}
public void setWidth (int ipWidth) //overrides
{
}
public void setHeight (int ipHeight)
{
}
//actions
public void draw (Graphics g, Image[] [] images, ImageObserver imgObs)
{
if (getColor () == Color.white)
{
g.setColor (Color.white);
g.fillRect (getCenterX () - getWidth () / 2, getCenterY () - getHeight () / 2, getWidth () + 1, getHeight () + 1);
}
else
{
if (isShowing)
{
g.drawImage (images [faceValue - 1] [suit - 1], getCenterX () - getWidth () / 2, getCenterY () - getHeight () / 2, getWidth (), getHeight (), imgObs);
}
}
}
}