-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTable.cpp
More file actions
68 lines (56 loc) · 1.19 KB
/
Copy pathTable.cpp
File metadata and controls
68 lines (56 loc) · 1.19 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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#include "Table.h"
Table::Table(){
}
std::vector<int> Table::getCards(){
return cards;
}
void Table::setCards(std::vector<int> _cards){
cards = _cards;
}
void Table::addCard(int card){
cards.push_back(card);
}
void Table::clear(){
cards.clear();
}
void Table::removeCards(std::vector<int> _cards){
for (int i = 0; i < _cards.size(); i++)
{
removeCard(_cards[i]);
}
}
bool Table::removeCard(int card){
bool hasTheCard = false;
int cardIndex = 0;
for(int i = 0; i < cards.size(); i++){
if (cards[i] == card){
hasTheCard = true;
cardIndex = i;
}
}
if (!hasTheCard){
return false;
}
cards.erase(cards.begin()+cardIndex);
return true;
}
bool Table::hasCard(int card){
bool hasTheCard = false;
for(int i = 0; i < cards.size(); i++){
if (cards[i] == card){
hasTheCard = true;
}
}
return hasTheCard;
}
int Table::countCards(){
return cards.size();
}
void Table::explain(){
std::cout << "Table Cards : ";
for(int i = 0; i < cards.size(); i++){
Card c(cards[i]);
std::cout << c.toString() << " ";
}
std::cout << endl;
}