-
Notifications
You must be signed in to change notification settings - Fork 18
Expand file tree
/
Copy pathaircraft.cpp
More file actions
75 lines (59 loc) · 1.43 KB
/
aircraft.cpp
File metadata and controls
75 lines (59 loc) · 1.43 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
//============================================================================
// Name : aircraft.cpp
// Author : Ak0s
//============================================================================
#include "aircraft.hpp"
using namespace std;
aircraft::aircraft() {
dmg = 0;
ammo = 0;
}
void aircraft::set_ammo(unsigned int ammo) {
this->ammo = ammo;
}
void aircraft::set_dmg(unsigned int dmg) {
this->dmg = dmg;
}
void aircraft::set_type(std::string type) {
this->type = type;
}
unsigned int aircraft::get_ammo() {
return ammo;
}
unsigned int aircraft::get_dmg() {
return dmg;
}
std::string aircraft::get_type() {
return type;
}
std::string aircraft::get_status() {
return "Type: " + type + ", Ammo: " + to_string(ammo) + ", Base Damage: " + to_string(dmg) + ", All Damage: " + to_string(ammo*dmg);
}
unsigned int aircraft::fight() {
unsigned int total_dmg = ammo * dmg;
ammo = 0;
return total_dmg;
}
unsigned int aircraft::refill(unsigned int& store_of_ammo) {
if (type == "F16") {
if (store_of_ammo > f16_max_ammo) {
ammo = f16_max_ammo;
store_of_ammo -= f16_max_ammo;
}
else {
ammo = store_of_ammo;
store_of_ammo = 0;
}
}
else if (type == "F35") {
if (store_of_ammo > f35_max_ammo) {
ammo = f35_max_ammo;
store_of_ammo -= f35_max_ammo;
}
else {
ammo = store_of_ammo;
store_of_ammo = 0;
}
}
return store_of_ammo;
}