-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDeck.cs
More file actions
52 lines (44 loc) · 1.27 KB
/
Deck.cs
File metadata and controls
52 lines (44 loc) · 1.27 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
using System.Linq;
using System.Collections.Generic;
class Deck {
private List<Card> cards;
public Deck() {
cards = new List<Card>();
}
public void add(Card card) {
if (cards.Contains(card)) {
throw new DeckIntegrityException("Cannot contain the same card twice!");
} else {
cards.Add(card);
}
}
public int size() {
return cards.Count;
}
public void populate() {
var Suits = new Suit[] {
Suit.Spades(),
Suit.Hearts(),
Suit.Clubs(),
Suit.Diamonds(),
};
foreach (var suit in Suits) {
cards.Add(Cards.aceOf(suit));
cards.Add(Cards.twoOf(suit));
cards.Add(Cards.threeOf(suit));
cards.Add(Cards.fourOf(suit));
cards.Add(Cards.fiveOf(suit));
cards.Add(Cards.sixOf(suit));
cards.Add(Cards.sevenOf(suit));
cards.Add(Cards.eightOf(suit));
cards.Add(Cards.nineOf(suit));
cards.Add(Cards.tenOf(suit));
cards.Add(Cards.jackOf(suit));
cards.Add(Cards.queenOf(suit));
cards.Add(Cards.kingOf(suit));
}
}
public List<Card> getCards() {
return cards;
}
}