-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDeck.cpp
More file actions
35 lines (27 loc) · 854 Bytes
/
Deck.cpp
File metadata and controls
35 lines (27 loc) · 854 Bytes
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
#include <random>
#include "Deck.h"
//We use the constructor of deck to create the cards
Deck::Deck() {
for (int suit = (int) Suits::CLUBS; suit < (int) Suits::endSuits; suit++) {
for (int value = (int) Values::TWO; value < (int) Values::endValues; value++) {
_cards.emplace_back(
Card(static_cast<Suits>(suit), static_cast<Values>(value)));
}
}
}
//We Call the card to string function and use it in the deckToString Function
void Deck::ToString() const {
for (auto &card: _cards) {
card.ToString();
}
}
//We shuffle the cards
void Deck::Shuffle() {
std::shuffle(this->_cards.begin(), this->_cards.end(), std::random_device());
}
//We can get a card
Card Deck::getCard() {
Card pickedCard = _cards.front();
_cards.erase(_cards.begin());
return pickedCard;
}