-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathblackjack.cpp
More file actions
41 lines (36 loc) · 764 Bytes
/
blackjack.cpp
File metadata and controls
41 lines (36 loc) · 764 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
#include "blackjack.h"
#include <iostream>
using namespace std;
int BlackjackHand::score()const{
int total_score=0;
for (int i=0; i<size(); i++){
Card c= card(i);
switch (c.value()){
case 'T':
case 'K':
case 'Q':
case 'J':
total_score+=10;
break;
case 'A':
total_score+=11;
break;
case '*':
break;
default:
total_score+= c.value()- '0';
}
}
for (int i=0; i<size(); i++)
if(card(i).value()=='A' && total_score>21)
total_score-=10;
return total_score;
}
int play(Deck& deck, int wager){
Hand dealer;
Hand player;
player.insert(deck.deal());
dealer.insert(deck.deal());
player.insert(deck.deal());
dealer.insert(deck.deal());
}