-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPlayer.cpp
64 lines (59 loc) · 1.15 KB
/
Player.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
#include "Player.hpp"
namespace Player {
float Player::GetMoney()
{
return Money;
}
vector<Bet::Bet*>* Player::GetBets()
{
return Bets;
}
void Player::Deposite(float deposite)
{
if (!CanDeposite(deposite))
throw new runtime_error("Deposite can't be less than 0!");
Money += deposite;
}
bool Player::CanDeposite(float deposite)
{
return deposite >= 0 ? true : false;
}
void Player::Withdrawal(float withdrawal)
{
if (!CanWithdrawal(withdrawal))
throw new runtime_error("Deposite can't be less than 0!");
Money -= withdrawal;
}
bool Player::CanWithdrawal(float withdrawal)
{
return withdrawal >= 0 && Money >= withdrawal ? true : false;
}
void Player::GiveBet(Bet::Bet* bet)
{
if (!bet->IsStop())
throw new runtime_error("Bet have to be finished!");
Money += bet->GetPay();
Bets->push_back(bet);
}
string Player::GetName()
{
return Name;
}
void Player::AddHand(Hand::Hand* hand)
{
Hands->push_back(hand);
}
void Player::ClearHands()
{
Hands->clear();
}
Player::~Player()
{
for (Bet::Bet* bet : *Bets)
delete bet;
delete Bets;
for (Hand::Hand* hand : *Hands)
delete hand;
delete Hands;
}
}