-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDirector.cpp
95 lines (81 loc) · 2.74 KB
/
Director.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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
#include "Director.h"
Director::Director(LaunchInterface *i, BaseStation *b, SpaceStation* s)
{
interface = i;
base_station = b;
space_station = s;
crewdragon_Bay = new CrewDragonBay();
dragon_Bay = new DragonBay();
starlink_Bay = new StarlinkBay();
engineer = new RocketshipEngineer(crewdragon_Bay, dragon_Bay, starlink_Bay);
command = new Work *[5];
command[0] = new CreateCrewDragon(engineer, interface, crewdragon_Bay, base_station);
command[1] = new CreateDragon(engineer, interface, dragon_Bay, base_station);
command[2] = new CreateStarlink(engineer, interface, starlink_Bay, base_station, space_station);
command[3] = new Backup(interface);
command[4] = new TestLaunch(interface);
command[5] = new OrderCargo(base_station,interface);
}
Director::~Director()
{
delete interface;
for (int i = 0; i < 6; i++)
delete command[i];
delete[] command;
delete crewdragon_Bay;
delete dragon_Bay;
delete starlink_Bay;
delete engineer;
}
void Director::makeCrewDragon()
{
command[0]->execute();
}
void Director::makeDragon()
{
command[1]->execute();
}
void Director::makeStarlink()
{
command[2]->execute();
}
void Director::createBackup()
{
command[3]->execute();
}
void Director::retrieveBackup()
{
command[3]->undo();
}
void Director::startTestLaunch()
{
command[4]->execute();
}
void Director::returnRocketship()
{
command[4]->undo();
}
void Director::receiveCargo()
{
command[5]->execute();
}
void Director::runMediator()
{
cout<<"\nDemonstrating StarlinkSatellites communication with Stations\n";
StarlinkCollection* SC = starlink_Bay->getRocketship();
StarlinkSatellite* ss =SC->getFirstSat();
ss->setStatus(false);
cout<<"StarlinkSatellite: "<<ss->getName()<<" was incorrectly configured ,notifying BaseStation of this error\n";
ss->NotifyStation();
cout<<"Status of the StarlinkSatellites ,the BaseStation is in communication with: \n";
map<int,bool> TempMap =SC->getCommunicationRelayBS()->getStatStatus();
for(map<int,bool>::iterator it =TempMap.begin();it!=TempMap.end();++it)
cout<<"name: "<<it->first<<" ,status: "<<it->second<<endl;
cout<<"BaseStation responds by fixing configuration on StarlinkSatellite "<<ss->getName()<<endl;
base_station->resolve(ss);
cout<<"New status of the StarlinkSatellites ,the BaseStation is in communication with: \n";
TempMap =SC->getCommunicationRelayBS()->getStatStatus();
for(map<int,bool>::iterator it =TempMap.begin();it!=TempMap.end();++it)
cout<<"name: "<<it->first<<" ,status: "<<it->second<<endl;
cout<<"End communication demonstration\n\n";
}