-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBank.cpp
82 lines (65 loc) · 1.98 KB
/
Bank.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
#include "Bank.h"
Bank::Bank()
{
//Set bankmoney equal to a random number!
_bankMoney = makeMoney();
}
void Bank::printBank() {
cout << string(100, '\n');
cout << " ______________________________________\n";
cout << " /-----------------BANK-----------------\\" << endl;
cout << " |......___________.....................|\n";
cout << " |.....|BANK HAS: |....................|\n";
cout << " |.....|$" << _bankMoney << " |....................|\n";
cout << " |.....| |....................|\n";
cout << " |......-----------.....................|\n";
cout << " |......................................|\n";
cout << " |......................................|\n";
cout << " |......................................|\n";
cout << " |......................................|\n";
cout << " |......................................|\n";
cout << " |......................................|\n";
cout << " |______________________________________|\n";
}
void Bank::askLoan() {
//ColaMachine object
ColaMachine cola;
//How much the user wants to get
bool loanGranted = false;
cout << string(100, '\n');
cout << "You do not have enough money!\n\n";
cout << "Would you like to take a loan?\n\n(1)-Yes\n(2)-No\n\n\n";
int choice;
cin >> choice;
switch (choice) {
case 1:
//Print the bank menu!
printBank();
while (loanGranted != true) {
cout << "Enter the amount to lend: $";
cin >> _loanValue;
if (_loanValue <= _bankMoney) {
cola.addMoney(_loanValue);
break;
}
else {
cout << "You entered too much! Try again..." << endl;
}
}
break;
case 2:
//User does not want to take a loan! Quit the game!
break;
default:
cout << "Bad input! Please retry..." << endl;
}
}
int Bank::makeMoney() {
static default_random_engine randomEngine(time(NULL));
uniform_int_distribution<int> money(20, 500);
_bankMoney = money(randomEngine);
return _bankMoney;
}
Bank::~Bank()
{
}