-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPlayer.cpp
More file actions
78 lines (60 loc) · 1.63 KB
/
Copy pathPlayer.cpp
File metadata and controls
78 lines (60 loc) · 1.63 KB
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
#include "Player.h"
#include "Dish.h"
#include <iostream>
#include <iomanip>
using namespace std;
Player::Player() {
income = 0;
xp = 0;
}
void Player::takeOrder() {
cout << "Taking order..." << endl;
cout << "Order taken!" << endl;
cout << "Get to cooking!" << endl;
addIncome(5);
gainXP(5);
cout << "You earned $5! And you gained 5 XP!" << endl;
}
void Player::cookDish(Dish* dish[], int dishIndex) {
if (xp < dish[dishIndex]->getMinXP()) {
cout << "You need at least " << dish[dishIndex]->getMinXP()
<< " XP to cook " << dish[dishIndex]->getName() << "!" << endl;
return;
}
cout << "Cooking " << dish[dishIndex]->getName() << endl;
cout << "Cooking..." << endl;
cout << "Dish cooked!" << endl;
dish[dishIndex]->increaseProficiency();
gainXP(dish[dishIndex]->getXPReward());
double earnings = dish[dishIndex]->getEarnings(dish[dishIndex]->getProficiency());
addIncome(earnings);
cout << "You earned $" << earnings << " and gained "
<< dish[dishIndex]->getXPReward() << " XP!" << endl;
}
void Player::sweep() {
cout << "Sweeping..." << endl;
addIncome(10);
gainXP(10);
cout << "You earned $10! And you gained 10 XP!" << endl;
;
}
void Player::gainXP(int i) {
xp += i;
}
void Player::resetIncome() {
income = 0;
}
void Player::addIncome(double amount) {
income += amount;
}
int Player::getXP() {
return xp;
}
double Player::getIncome() {
return income;
}
void Player::displayStats() {
cout << "XP: " << xp << endl;
cout << fixed << setprecision(2);
cout << "Income: $" << income << endl;
}