-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathHand.cpp
More file actions
executable file
·43 lines (33 loc) · 790 Bytes
/
Hand.cpp
File metadata and controls
executable file
·43 lines (33 loc) · 790 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
36
37
38
39
40
41
42
43
#include <iostream>
#include <assert.h>
#include "Hand.h"
Hand::Hand() {
}
Hand::Hand(const vector<Card> &cards) {
this->cards = cards;
}
Card Hand::turn() {
/* Returns the first card and removes it from the hand */
Card card = cards.front();
cards.erase(cards.begin());
return card;
}
void Hand::addCards(const vector<Card> &cards) {
/* Add cards to hand */
vector<Card>::iterator iter = this->cards.end();
this->cards.insert(iter, cards.begin(), cards.end());
}
void Hand::show() {
/* Print all cards */
cout << asString();
cout << endl;
}
string Hand::asString() {
string result;
for (int i = 0; i < cards.size(); i++)
result += cards[i].asString() + " ";
return result;
}
int Hand::cardCount() {
return cards.size();
}