-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCard.java
72 lines (60 loc) · 1.15 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
69
70
71
72
public class Card {
private String name;
private cardSuit suit;
private cardColor color;
private String binaryNum;
protected enum cardColor{
RED,
BLACK,
}
protected enum cardSuit{
SPADES,
CLUBS,
DIAMONDS,
HEARTS
}
public String getName() {
return this.name;
}
public void setSuit(int suitNum) {
switch(suitNum) {
case 1:
this.suit = cardSuit.SPADES;
break;
case 2:
this.suit = cardSuit.CLUBS;
break;
case 3 :
this.suit = cardSuit.DIAMONDS;
break;
case 4:
this.suit = cardSuit.HEARTS;
break;
default:
break;
}
if(suit.equals(cardSuit.SPADES) || suit.equals(cardSuit.CLUBS)) {
this.color = cardColor.BLACK;
binaryNum = "0";
} else {
this.color = cardColor.RED;
binaryNum = "1";
}
}
public String getSuit() {
return this.suit.toString();
}
public cardColor getcolor() {
return color;
}
public String toString() {
return this.getName() + "(" + this.getSuit() + ")";
}
public String getBinary() {
return binaryNum;
}
public Card(String name) {
this.name = name;
this.suit = suit;
}
}