-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbjRuleController.cpp
94 lines (78 loc) · 2.15 KB
/
bjRuleController.cpp
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
//Topic 13: Object Orientation: Inheritance
#include "bjRuleController.h"
#include <fstream>
bjRuleController::bjRuleController() {
dealerMaxPoints = 17;
reshuffelTrigger = 75;
numberOfDecks = 6;
initChips = 1000;
minBet = 2;
maxBet = 500;
}
void bjRuleController::printRules() {
std::string line;
std::ifstream file;
file.open("bjRules.txt");
//Topic 9: Kontrollfluß: grundlegende Kontrollstrukturen
if (file.is_open()) {
//Topic 9: Kontrollfluß: grundlegende Kontrollstrukturen
while (std::getline(file, line)) {
std::cout << line << std::endl;
}
}
printf("\n\n\n");
}
void bjRuleController::playerWin() {
printf("\n\n\n\n******************************************\n");
printf("\t\tYou have won your bet is multiplied by 2\n");
}
void bjRuleController::playerLoose() {
printf("\n\n\n\n******************************************\n");
printf("\t\tYou lost.\n");
}
void bjRuleController::playerTie() {
printf("\n\n\n\n******************************************\n");
printf("\t\tTie. You get your bet back\n");
}
int bjRuleController::getDealerMaxPoints() const {
return dealerMaxPoints;
}
int bjRuleController::getReshuffelTrigger() const {
return reshuffelTrigger;
}
int bjRuleController::getNumberOfDecks() const {
return numberOfDecks;
}
int bjRuleController::getInitChips() const {
return initChips;
}
int bjRuleController::getMinBet() const {
return minBet;
}
int bjRuleController::getMaxBet() const {
return maxBet;
}
playerStatus bjRuleController::winLossTieControll(int pValue, int dValue) {
//Topic 9: Kontrollfluß: grundlegende Kontrollstrukturen
if (pValue > 21) {
playerLoose();
return LOSS;
} else if (pValue == 21) {
if (dValue == 21) {
playerTie();
return TIE;
}
} else {
if (dValue <= 21) {
if (pValue < dValue) {
playerLoose();
return LOSS;
} else if (pValue == dValue) {
playerTie();
return TIE;
}
}
}
playerWin();
return VICTORY;
}