-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathInventory.cpp
50 lines (40 loc) · 1.04 KB
/
Inventory.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
#include "Inventory.hpp"
Inventory::Inventory(QObject* parent, int initialEggCount, int initialCoinCount, std::vector<Pet>& user_list)
: QObject(parent), eggCount(initialEggCount), coinCount(initialCoinCount), user_list(user_list){}
void Inventory::setEggCount(int egg) {
eggCount = egg;
// std::cout << "egg count set to " << eggCount << std::endl;
}
void Inventory::setCoinCount(int coin) {
coinCount = coin;
// std::cout << "coin count set to " << coinCount << std::endl;
}
int Inventory::getEggCount() const {
return eggCount;
}
int Inventory::getCoinCount() const {
return coinCount;
}
void Inventory::addEgg() {
eggCount += 6;
std::cout << "egg: " << eggCount << std::endl;
}
int Inventory::removeEgg() {
eggCount -= 1;
if (eggCount < 0) {
eggCount = 0;
return -1;
}
return 0;
}
void Inventory::addCoin(int count) {
coinCount += count;
}
int Inventory::removeCoin(){
coinCount -= 7;
if (coinCount < 0) {
coinCount += 7;
return -1;
}
return 0;
}