forked from Ak0s/zerda-exam-cpp-foundations
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCarrier.cpp
More file actions
65 lines (58 loc) · 1.5 KB
/
Carrier.cpp
File metadata and controls
65 lines (58 loc) · 1.5 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
/*
* Carrier.cpp
*
* Created on: 2016. dec. 6.
* Author: Tecra_Z50
*/
using namespace std;
#include "Carrier.h"
#include "AirCraft.h"
Carrier::Carrier() : AirCraft() {
num_aircraft = 0;
}
void Carrier::add_to_vector(string input) {
if (input == "F16") {
aircraft_type = "F16";
vector<Carrier*> myVector;
Carrier* p = NULL;
for (unsigned int i = 0; i < num_aircraft; i++) {
p = new Carrier();
myVector.push_back(p);
}
delete p;
p = NULL;
num_aircraft++;
}
else if (input == "F35") {
aircraft_type = "F35";
vector<Carrier*> myVector;
Carrier* p = NULL;
for (unsigned int i = 0; i < num_aircraft; i++) {
p = new Carrier();
myVector.push_back(p);
}
delete p;
p = NULL;
num_aircraft++;
}
else {
}
}
string Carrier::get_all_status() {
return "Aircraft count: " + to_string(num_aircraft) + ", Ammo Storage: " + to_string(ammo_storage) + "\n"+
"Aircrafts: \n"
"Type " + aircraft_type + ", Ammo: " + to_string(actual_ammo) + ", Base Damage: " + to_string(base_damage) +
", All Damage: " + to_string(damage) + "\n";
}
unsigned int Carrier::fill_all_aircraft(int &ammo_storage) throw (const char*) {
if (ammo_storage < (max_ammo - actual_ammo)) {
actual_ammo = max_ammo;
ammo_storage -= actual_ammo;
return ammo_storage;
}
else {
throw "Error: Cannot fill, ammo storage not enough.";
}
}
Carrier::~Carrier() {
}