-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDeck.java
88 lines (78 loc) · 1.97 KB
/
Deck.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
86
87
88
package java6CodingAssignment;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
public class Deck {
public List<Card> cards = new ArrayList<Card>();
public Deck() {
for(int i =2; i <=14; i++) {
String cardFullName = i + " of Hearts";
if(i == 11) {
cardFullName = "Jack of Hearts";
} else if (i == 12){
cardFullName = "Queen of Hearts";
} else if (i == 13){
cardFullName = "King of Hearts";
} else if (i == 14){
cardFullName = "Ace of Hearts";
}
Card card = new Card(i, cardFullName);
cards.add(card);
}
for(int i =2; i <=14; i++) {
String cardFullName = i + " of Diamonds";
if(i == 11) {
cardFullName = "Jack of Diamonds";
} else if (i == 12){
cardFullName = "Queen of Diamonds";
} else if (i == 13){
cardFullName = "King of Diamonds";
} else if (i == 14){
cardFullName = "Ace of Diamonds";
}
Card card = new Card(i, cardFullName);
cards.add(card);
}
for(int i =2; i <=14; i++) {
String cardFullName = i + " of Spades";
if(i == 11) {
cardFullName = "Jack of Spades";
} else if (i == 12){
cardFullName = "Queen of Spades";
} else if (i == 13){
cardFullName = "King of Spades";
} else if (i == 14){
cardFullName = "Ace of Spades";
}
Card card = new Card(i, cardFullName);
cards.add(card);
}
for(int i =2; i <=14; i++) {
String cardFullName = i + " of Clubs";
if(i == 11) {
cardFullName = "Jack of Clubs";
} else if (i == 12){
cardFullName = "Queen of Clubs";
} else if (i == 13){
cardFullName = "King of Clubs";
} else if (i == 14){
cardFullName = "Ace of Clubs";
}
Card card = new Card(i, cardFullName);
cards.add(card);
}
}
public void shuffle() {
Collections.shuffle(cards);
}
public Card draw() {
Card drawnCard = cards.get(0);
cards.remove(0);
return drawnCard;
}
public void describe() {
for (Card card:cards) {
card.describe();
}
}
}