-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCard.java
More file actions
66 lines (65 loc) · 947 Bytes
/
Card.java
File metadata and controls
66 lines (65 loc) · 947 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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
public class Card
{
private int rank;
private String suit;
private boolean isFaceUp;
public Card(int r, String s)
{
rank = r;
suit = s;
isFaceUp = false;
}
public int getRank()
{
return rank;
}
public String getSuit()
{
return suit;
}
public boolean isRed()
{
return suit.equals("d") || suit.equals("h");
}
public boolean isFaceUp()
{
return isFaceUp;
}
public void turnUp()
{
isFaceUp = true;
}
public void turnDown()
{
isFaceUp = false;
}
public String getFileName()
{
if (!isFaceUp())
{
return "cards/back.gif";
}
else
{
String file = "cards/";
if (rank >= 2 && rank <= 9)
file += rank;
else
{
if (rank == 10)
file += "t";
else if (rank == 11)
file += "j";
else if (rank == 12)
file += "q";
else if (rank == 13)
file += "k";
else if (rank == 1)
file += "a";
}
file += suit;
file += ".gif";
return file;
}
}
}