-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
108 lines (80 loc) · 3.14 KB
/
main.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
96
97
98
99
100
101
102
103
104
105
106
107
108
#include "Person.h"
#include "Mission.h"
#include "Agency.h"
#include <iostream>
#include <cstdlib>
using namespace std;
// Initialize the static member
int Mission::numMissions = 0;
int main(int argc, char const *argv[])
{
// Set the PRNG seed
srand(1773);
cout << "*** Agency creation ***" << endl;
// Create agency with given name, cash and ticket price
Agency newAgency = Agency("NASA",20000,-40);
cout << newAgency;
// Set the ticket price which is set to 0 before
newAgency.setTicketPrice(10000);
// Print agency information
cout << newAgency;
// Execute the next mission
newAgency.executeNextMission();
cout << endl << "*** Astronaut creation ***" << endl;
// Create astronauts
Astronaut* astronautList[5];
astronautList[0] = new Astronaut("Neil","Armstrong",3);
astronautList[1] = new Astronaut("Buzz","Aldrin",-4);
astronautList[2] = new Astronaut("Sally","Ride");
astronautList[3] = new Astronaut("Judith","Resnik",4);
astronautList[4] = new Astronaut("Yuri","Gagarin",5);
cout << endl << "*** Passenger creation ***" << endl;
// Create astronauts
Passenger* passengerList[5];
passengerList[0] = new Passenger("Dennis","Tito",12000);
passengerList[1] = new Passenger("Mark","Shuttleworth",10000);
passengerList[2] = new Passenger("Gregory","Olsen",15000);
passengerList[3] = new Passenger("Charles","Simonyi",24000);
passengerList[4] = new Passenger("Alperen","Kantarcı");
// Every passenger tries to buy a ticket
for(int i=0; i<5; i++){
passengerList[i]->buyTicket(newAgency.getTicketPrice());
}
cout << endl << "*** Moon mission creation ***" << endl;
// Create moon mission
Mission moonMission = Mission("MN-01",5000,20);
moonMission += astronautList[0];
moonMission += astronautList[1];
moonMission += astronautList[2];
moonMission += passengerList[0];
moonMission += passengerList[1];
moonMission += passengerList[2];
newAgency.addMission(moonMission);
cout << endl << "*** Venus mission creation ***" << endl;
// Create venus mission
Mission venusMission = Mission("VENUS-01",35000,80);
cout << "Name of the mission: " << venusMission.getName() << endl;
venusMission.setName("VS-01");
venusMission += astronautList[3];
venusMission += astronautList[4];
venusMission += passengerList[3];
venusMission += passengerList[4];
newAgency.addMission(venusMission);
cout << endl << "*** Mission creation finished ***" << endl;
// Show information of the agency
cout << newAgency;
cout << endl << "*** Lift off ***" << endl;
// Execute next mission
newAgency.executeNextMission();
cout << newAgency;
cout << endl << "*** Lift off ***" << endl;
// Execute another mission
newAgency.executeNextMission();
cout << newAgency << endl;
// Delete the allocated space
for(int i=0; i<5; i++){
delete astronautList[i];
delete passengerList[i];
}
return 0;
}