-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAIRPORT MANAGEMENT using array.cpp
194 lines (170 loc) · 3.1 KB
/
AIRPORT MANAGEMENT using array.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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
//using dynamic array
#include<bits/stdc++.h>
using namespace std;
struct Flight{
int id;
int level;
string status;
int pscore;
}
class Runway{
private:
int gensize;
int gencap;
int emersize;
int emercap;
Flight* general;
Flight* emergency
public:
Runway(){
gensize=0;
gencap=5;
emersize=0;
emercap=1;
Flight* general=new[gencap];
Flight* emergency=new[emercap];
}
~Runway()
{
delete[]general;
delete[]emergency;
}
void insertx(int id,int level,string status)
{
Flight nc;
nc.status=status;
nc.level=level;
nc.status=status;
if(status=="E")
{
useemergency();
}
else{
general[emersize++]=nc;
}
if(gensize==gencap)
{
useemergency();
}
}
/*void regenral()
{
newgencap =gencap *2;
for(int i=0;i<gencap;i++)
{
newgencap[i]=gencap[i];
}
delete gencap;
gencap=newgencap;
}
void reemer()
{
newemercap =emercap *2;
for(int i=0;i<emercap;i++)
{
newemercap[i]=emercap[i];
}
delete emercap;
emercap=newemercap;
} */
void usegeneral()
{
for(int i=0;i<gensize;i++)
{
general[i]=general[i+1];
}
gensize--;
cout<<"Flight landed on general path"<<endl;
}
void useemergency()
{
for(int i=0;i<gensize;i++)
{
emergency[i]=emergency[i+1];
}
emersize--;
cout<<"Flight landed on emergency path"<<endl;
}
void displaygen(){
for(int i=0;i<gensize;i++)
{
cout<<nc.id<<endl;
}
}
void displayemer(){
for(int i=0;i<emersize;i++)
{
cout<<nc.id<<endl;
}
}
void calcPriorityScore()
{
int priority=0;
if(int pscore<=fuellevel)
{
priority++;
fuellevel=pscore;
cout<<"Flight with the lowest fuel level"<<endl;
cout<<fuellevel<<endl;
}
}
};
int main(){
Runway r;
cout<<"Airport management"<<endl;
cout<<"1.Add flights to general path"<<endl;
cout<<"2.Allow landing on general runway"<<endl;
cout<<"3.Allow landing on gemergency runway"<<endl;
cout<<"4.Open emergency runway"<<endl;
cout<<"5.Add flights to general path"<<endl;
cout<<"6.View general path"<<endl;
cout<<"7.View emergency path"<<endl;
cout<<"8.Exit"<<endl;
cout<<"Enter your choice"<<endl;
int choice;
cin>>choice;
if(choice==1)
{
int id,level;
string status;
cin>>id>>level>>status;
r.insertx(id,level,status);
}
else if(choice==2)
{
r.usegeneral();
}
else if(choice==3)
{
r.useemergency();
}
else if(choice==4)
{
r.calcPriorityScore();
int countx=0;
Flight* current=general;
if(current=current->next)
{
countx++;
cout<<countx<<endl;
cout<<"Showing the flights from the emergency counter based on priority levels"<<endl;
}
}
else if(choice==5)
{
r.displaygen();
}
else if(choice==6)
{
r.displayemer();
}
else if(choice==7)
{
r.calcavg();
}
else(choice==8)
{
cout<<"Exiting the program"<<endl;
}
return 0;
}