-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathOxygen_Depot.cpp
More file actions
72 lines (66 loc) · 1.62 KB
/
Copy pathOxygen_Depot.cpp
File metadata and controls
72 lines (66 loc) · 1.62 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
#include <iostream>
using namespace std;
#include "Oxygen_Depot.h"
#include "Game_Object.h"
//Constructors
Oxygen_Depot::Oxygen_Depot(): Game_Object('O')
{
amount_oxygen = 50;
state = 'f';
cout << "Oxygen_Depot default constructed" << endl;
}
Oxygen_Depot::Oxygen_Depot(Cart_Point inputLoc, int inputId):Game_Object('O')
{
amount_oxygen = 50;
id_num = inputId;
location = inputLoc;
state = 'f';
cout << "Oxygen_Depot constructed" << endl;
}
//Public Member Functions
bool Oxygen_Depot::is_empty()
{
if (amount_oxygen == 0)
return true;
else
return false;
}
double Oxygen_Depot::extract_oxygen(double amount_to_extract)
{
if (amount_oxygen > amount_to_extract || amount_oxygen == amount_to_extract)
{
amount_oxygen -= amount_to_extract;
return amount_to_extract;
}
else
{
double current_oxy = amount_oxygen;
amount_oxygen = 0;
return current_oxy;
}
}
bool Oxygen_Depot::update()
{
if (amount_oxygen == 0)
{
if (state == 'e')
return false; // nothing happened because it already knows depot is empty
state = 'e'; // depot is empty
display_code = 'o'; //signifies a deteriorated depot
cout << "Oxygen_Depot " << id_num << " has been depleted." << endl;
return true; // signifies an event happened
}
else
return false; //signifies nothing happened
}
void Oxygen_Depot::show_status()
{
cout << "Oxygen Depot status: ";
Game_Object::show_status();
cout << " at location " << location;
cout << " contains " << amount_oxygen << "." << endl;
}
Oxygen_Depot::~Oxygen_Depot()
{
cout << "Oxygen_Depot destructed." << endl;
}