-
Notifications
You must be signed in to change notification settings - Fork 0
/
carddeck.cpp
45 lines (36 loc) · 961 Bytes
/
carddeck.cpp
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
//
// Created by iDarkDuck on 2018-10-19.
//
#include "carddeck.h"
#include "cassert"
//#define TEST_CARD_DECK
CardDeck::CardDeck() : Deck() {
deck = new vector<Card *>();
for (int i = 0; i != Colors; ++i)
for (int j = 0; j != Animals; ++j) deck->emplace_back(new Card{(FaceAnimal) j, (FaceBackground) i});
}
CardDeck::~CardDeck() {
for (auto &it : *deck) { delete it; }
delete deck;
}
CardDeck &CardDeck::make_CardDeck() {
static CardDeck c;
c.shuffle();
return c;
}
#ifdef TEST_CARD_DECK
int main() {
cout << "TEST_CARD_DECK" << endl;
CardDeck &c = CardDeck::make_CardDeck();
for (int i = 0; i < 25; i++) {
assert(!c.isEmpty());
cout << i << endl;
Card *card = c.getNext();
cout << *card << endl;
cout << "Animal " << card->getAnimal() << endl;
cout << "Colour " << card->getColor() << endl;
cout << endl;
}
assert(c.isEmpty());
}
#endif