-
Notifications
You must be signed in to change notification settings - Fork 0
/
Capsule.cpp
43 lines (35 loc) · 836 Bytes
/
Capsule.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
#include "Capsule.h"
using namespace std;
Capsule* Capsule::instance;
Capsule::Capsule():City("TARDIS") {
this->working = true;
GameVariables::year = 2015;
}
Capsule* Capsule::getInstance() {
if (!instance)
instance = new Capsule();
return instance;
}
bool Capsule::getWorking() {
return this->working;
}
void Capsule::setWorking(bool working) {
this->working = working;
}
int Capsule::getYear() {
return GameVariables::year;
}
void Capsule::setYear(int year) {
if (!this->working) {
cout << "Your TARDIS isn't working" << endl;
return;
}
GameVariables::year = year;
if (rand() % 10 == 0) {
cout << "Your TARDIS has broken down, no time travel from now on" << endl;
this->setWorking(false);
}
}
Capsule::~Capsule() {
delete instance;
}