-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbjHand.cpp
59 lines (47 loc) · 1.51 KB
/
bjHand.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
//Topic 14: Object Orientation: Interface vs. Implementation *
#include "bjHand.h"
int bjHand::payout() const {
return betAmount * 2;
}
void bjHand::resetBetamount() {
betAmount = 0;
}
void bjHand::giveCard(const std::shared_ptr<bjCards> &card) {
deck.addCardtoDeck(card);
}
void bjHand::showcards() {
//Topic 9: Kontrollfluß: grundlegende Kontrollstrukturen
for (const std::shared_ptr<bjCards> &card: deck.getDeck()) {
card->whoAmI();
}
}
void bjHand::bet(int playerBet) {
betAmount = playerBet;
}
int bjHand::givePlayerBetBack() const {
return betAmount;
}
void bjHand::showfirstCard() {
deck.getDeck().front()->whoAmI();
}
int bjHand::getPlayerTotalvalue(bool player) {
//Topic 9: Kontrollfluß: grundlegende Kontrollstrukturen
if (player) {
//Topic 9: Kontrollfluß: grundlegende Kontrollstrukturen
//Topic 26: Häufige fehlerquellen -> Index out of Bounds wird durch for each abgefangen
for (const std::shared_ptr<bjCards> &card: deck.getDeck()) {
//Topic 9: Kontrollfluß: grundlegende Kontrollstrukturen
if (card->getNumber() == "A") {
//Topic 9: Kontrollfluß: grundlegende Kontrollstrukturen
if (deck.getTotalValue() > 21) {
card->setValue(1);
}
}
}
}
return deck.getTotalValue();
}
bjHand::bjHand() = default;
void bjHand::showValue(bool player) {
printf("The cards have a value of: %i\n", getPlayerTotalvalue(player));
}