-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGenericPlayer.cpp
More file actions
63 lines (53 loc) · 1.13 KB
/
GenericPlayer.cpp
File metadata and controls
63 lines (53 loc) · 1.13 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
#include <iostream>
#include <string>
#include <vector>
#include "GenericPlayer.h"
#include "Deck.h"
#include "Hand.h"
using namespace std;
GenericPlayer::GenericPlayer()
{
buss = false;
hit = false;
}
GenericPlayer::GenericPlayer(string n)
{
buss = false;
name = n;
hit = false;
}
bool GenericPlayer::isBusted() const
{
if (getTotal() > 21)
return true;
return false;
}
void GenericPlayer::bust() const
{
cout << name << " busts." << endl;
}
bool GenericPlayer::isHitting() const
{
string ans;
cout << name << ", Are you taking another hit? (y/n): ";
cin >> ans;
while (ans != "y" && ans != "n" && ans != "Y" && ans != "N")
{
cout << "Wrong input. Are you taking another hit? (y/n): ";
cin >> ans;
}
if (ans == "y" || ans == "Y")
return true;
else return false;
}
void GenericPlayer::display() const
{
cout << name << ": ";
for (auto card: stack)
cout << card.show() << " ";
cout << getTotal() << endl;
}
string GenericPlayer::getName() const
{
return name;
}