-
Notifications
You must be signed in to change notification settings - Fork 0
/
Card.java
68 lines (67 loc) · 1.04 KB
/
Card.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
/*
Dylan Inafuku
2375529
CPSC 231-02
MP3: Modern War(fare)
*/
public class Card
{
// Member variables
int value; // 2-10, J = 11; Q = 12; K = 13; A = 14
String suit; // clubs, diamonds, hearts, spades
// Default constructor
public Card()
{
value = 0;
suit = null;
}
// Overloaded constructor
public Card(int value, String suit)
{
this.value = value;
this.suit = suit;
}
// Accessors
public int getValue()
{
return value;
}
public String getSuit()
{
return suit;
}
// Mutators
public void setInt(int value)
{
this.value = value;
}
public void setSuit(String suit)
{
this.suit = suit;
}
// toString to print cards neatly, used in testing/debugging
public String toString()
{
if (value == 11)
{
return "J" + suit;
}
if (value == 12)
{
return "Q" + suit;
}
if (value == 13)
{
return "K" + suit;
}
if (value == 14)
{
return "A" + suit;
}
else
{
return value + suit;
}
}
}