-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCrewDragon.cpp
50 lines (43 loc) · 1.22 KB
/
CrewDragon.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 "CrewDragon.h"
CrewDragon::CrewDragon() : Capsule("Crew Dragon") {
this->capacity = 8;
}
CrewDragon::~CrewDragon()
{
if (crew.size() != 0)
{
std::vector<Crew *>::iterator it;
std::cout << "---------------------------------------------\n";
for (it = crew.begin(); it != crew.end(); it++)
delete (*it);
(*it) = nullptr;
}
}
void CrewDragon::unloadCrew()
{
std::vector<Crew *>::iterator it;
std::cout << "Unloading the following Crew: \n";
for (it = crew.begin(); it != crew.end(); it++)
{
std::cout << "Name: "<< (*it)->getName() << "\tSpecialisation: " << (*it)->getSpecialisation() << std::endl;
delete (*it);
}
std::cout << crew.size() << " - Crew Size\n";
crew.clear();
}
void CrewDragon::unloadContents()
{
std::cout << "Unloading Cargo from the CrewDragon Capsule\n";
}
bool CrewDragon::addCrew(Crew * person)
{
if (crew.size() == capacity)
{
std::cout << "No more crew members can fit in this capsule\n";
return false;
}
std::cout << "Adding " << person->getName() << " \n";
crew.push_back(person);
return true;
}
void CrewDragon::removeCrew() { this->crew.clear(); }