-
Notifications
You must be signed in to change notification settings - Fork 0
/
dealer.hpp
45 lines (37 loc) · 902 Bytes
/
dealer.hpp
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
#include <iostream>
using namespace std;
class Dealer {
private:
vector<Card> hand;
int sum, index, win;
public:
Dealer(): hand(5) {
sum=0; index=0; win=0;
}
int checkSum() {
if(sum > 21) {
win = 2;
}
if(sum == 21) {
win = 3;
}
return win;
}
bool addCard() {
hand[index].dealCard();
sum += hand[index].getNumber();
index++;
if(checkSum() == 2) {
cout << "\n Dealer busted (Sum: " << getSum() << ")\n";
return 0;
}
else if(checkSum() == 3){
cout << "Blackjack!";
return 0;
}
return 1;
}
int getSum() {
return sum;
}
};