-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
140 lines (102 loc) · 3.26 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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
/*
* John Sadiq
* CS 281 Fall 2019
* Airport Project
*
* Plane.cpp
*
*
*
*/
#include "Airport.h"
using namespace std;
int main()
{
//sets time to be 0 so when the time of the programmed is run and a new plane is created, It will be random
srand(unsigned int (time(0)));
Airport* Aport = new Airport();
//Introduction
cout << "Welcome to the San Diego Airlines! \n" <<
"Enter l to have simulation go one cycle \n" <<
"Then enter a number for the given options \n" <<
"1) Create a new plane \n" <<
"2) Check status on all planes \n" <<
"3) Check list of landed planes \n" <<
"4) Check list of crashed planes \n" <<
"5) Loops all planes until all planes are on the ground \n" <<
"Enter q to quit \n" <<
"----------------------------------------- \n";
// sets a variable for input, for the do while loop
//allowing a quit option for user
string input;
//loops until user decides to quit
do
{
//Variables
string name;
int fuel;
int type;
//Adds >> to show where user will enter their imput
cout << "\n >>";
cin >> input;
//switch giving the user options to choose
switch (input.at(0))
{
case 'l': // Simulate loop
//loops once through the list
Aport->simLoop();
//displays the status of planes
Aport->showStatus();
/*
one cycle goes through with every space buttom pressed,
plane does a lap and 5% of fuel is lost, one plane lands per cycle
*/
break;
case '1': //New Plane
// user enter values for name and type
cout << "Enter Plane Name: ";
cin >> name;
cout << "Would you like plane type to be \n 1) Private 2) Commercial 3) Air Force 1 :";
cin >> type;
//Random fuel for new plane, fuel can only be between 10% - 90%
fuel = rand() % 90 + 10;
//Sends values the user inputed to the Airport.cpp to go through algorithm
Aport->CreatePlane(name, fuel, type);
/*
creates new plane, sets a random number between 10-90 for fuel percent,
set priority depending on plane type, user inputs name for plane, set plane status
*/
break;
case '2': //check status
//COUT msg
cout << "current status of all planes \n";
cout << "---------------------------- \n";
//Show Status, background work is in Airport.cpp
Aport->showStatus();
break;
case '3': // Show stack of LANDED planes
//COUT msg
cout << "List of landed planes \n";
cout << "--------------------- \n";
//Show Stack of landed planes, background work is in Airport.cpp
Aport->landedstackShow();
break;
case '4': // Show stack of CRASHED planes
//COUT msg
cout << "List of crashed planes \n";
cout << "---------------------- \n";
//Show Stack of crashed planes, background work is in Airport.cpp
Aport->crashedstackShow();
break;
case '5': //loops until all planes are either landed or crashed
//COUT msg
cout << "Looped through all planes \n";
cout << "------------------------- \n";
//completes simloop until empty
Aport->fullsimLoop();
break;
}
//When user enters 'q' the program quits
} while (input != "q");
return 0;
}