-
Notifications
You must be signed in to change notification settings - Fork 0
/
Airplane.cpp
366 lines (335 loc) · 7.61 KB
/
Airplane.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
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
#include"Airplane.h"
#include<windows.h>
#include<iostream>
using namespace std;
int Airplane::radar = 0;
Airplane::Airplane()
: blackbox()
{
on_air = false;
gps = false;
transponder = false;
piloto_auto = false;
speed =0;
distance =0;
freeseats =6;
}
Airplane::Airplane( const Airplane &aviao ){
on_air = aviao.on_air;
gps = aviao.gps;
transponder = aviao.transponder;
piloto_auto = aviao.piloto_auto;
speed = aviao.speed;
distance = aviao.distance;
blackbox = aviao.blackbox;
}
float Airplane::getSpeed()const{
return speed;
}
float Airplane::getDistance()const{
return distance;
}
void Airplane::DisplayMessage()const{
Wait();
cout <<"\nData Default: " << endl;
blackbox.print();
cout << "\nStatus dos instrumentos:" << endl;
if ( gps == false){
cout <<"Gps desligado..." << endl;
}
else{
cout <<"Gps ligado e funcionando..." << endl;
}
if ( transponder == false){
cout <<"transponder desligado..." << endl;
}
else{
cout <<"Tranponder ligado e funcionando..." << endl;
}
if ( piloto_auto == false){
cout <<"Piloto automatico desligado..." << endl;
}
else{
cout <<"Piloto automatico ligado e funcionando..." << endl;
}
if ( on_air == false){
cout <<"Airplane ainda em solo..." << endl;
}
else{
cout <<"Airplane no ar..." << endl;
}
}
float Airplane::getAux()const{
return aux;
}
void Airplane::Gps(){
if ( gps == false ){
gps = true;
Wait();
cout <<"\nGps ligado e funcionando..." << endl;
}
else{
Wait();
cout <<"\nGps desligado..." << endl;
gps = false;
}
}
void Airplane::Transponder(){
if ( transponder == false){
this->transponder = true;
radar++;
Wait();
cout <<"\nTransponder ligado e funcionando..." << endl;
}
else
{
this->transponder = false;
radar--;
Wait();
cout <<"\nTransponder desligado..." << endl;
}
}
void Airplane::Piloto_auto(){
if ( on_air == false){
Wait();
cout << "\nErro helios One ainda em solo...\n" << endl;}
else if ( gps && transponder == false ){
Wait();
cout << "\nGps e Transponder desligados..." << endl;
}
else if ( piloto_auto == true ){
piloto_auto = false;
Wait();
cout <<"\nPiloto automatico desligado..." << endl;
}
else{
piloto_auto = true;
Wait();
cout <<"\nPiloto automatico ligado e funcionando..." << endl;
}
}
void Airplane::Display(){
int aux;
do{
cout << "\nDisplay de Instrumentos: \n"
<< "Ligar Gps -1-\n"
<< "Ligar Transponder -2-\n"
<< "Ligar Piloto automatico -3-\n"
<< "Mostrar status dos insturmnetos -4-\n"
<< "Iniciar decolagem -5-\n"
<< "Alterar parametros de voo -6-\n"
<< "Mostrar Radar -7-\n"
<< "Embarque de passageiros -8-\n"
<< "Lista de passageiros -9-\n"
<< "Sair do Display insturmnetos -0-\n";
cout << endl;
cin >> aux;
switch (aux){
case 1:
system("cls");
Gps();
break;
case 2:
system("cls");
Transponder();
break;
case 3:
system("cls");
Piloto_auto();
break;
case 4:
system("cls");
DisplayMessage();
cout <<"\n";
break;
case 5:
system("cls");
TakeOff();
cout <<"\n";
break;
case 6:
system("cls");
ChangeFlight();
cout <<"\n";
break;
case 7:
system("cls");
getRadar();
cout <<"\n";
break;
case 8:
system("cls");
setPassenger();
cout <<"\n";
break;
case 9:
system("cls");
getPassenger();
cout <<"\n";
break;
default:
cout << "Esclolha Invalida..." << endl;}
} while ( aux != 0);
}
void Airplane::Speed(){
cout << "Velocidade desejada em Km/h: " << endl;
int op;
do{
cin >> this->speed;
if ( this->speed < 100)
{
cout << "Impossivel ganhar ou manter altitude a esta velocidade..." << endl;
op =0;
}
else if( this->speed > 300)
{
cout << "Velocidade maxima excedida..." << endl;
op = 0;
}
else
{
this->speed = this->speed;
op = 1;
}
} while ( op == 0);
}
void Airplane::Distance(){
int op;
cout <<"Distancia do destino em km: " << endl;
if ( on_air == false)
{
do{
cin >> this->distance;
if ( distance > 1800 ){
cout <<"Distancia excede a autonomia do Airplane..." << endl;
op = 0;
}
else if ( distance <= 0 ){
cout <<"Distancia invalida..." << endl;
op = 0;
}
else{
distance = distance;
op = 1;
}
} while ( op == 0);
}
else // Alterar distancia em voo
{
cout << "Airplane jah percorreu: " << distance << endl;
cout << "Autonomia restante :" << 1800 - distance << endl;
cout << "Nova distancia do destino em km: " << endl;
this-> aux = this-> distance;
do{
cin >> this-> distance;
if ( aux + distance > 1800 ){
cout <<"Distancia excede a autonomia do Airplane..." << endl;
op = 0;
}
else if ( distance < 0 ){
cout <<"Distancia invalida..." << endl;
op = 0;
}
else{
distance = distance;
op = 1;
}
} while ( op == 0);
}
}
void Airplane::TakeOff(){
if ( transponder == false )
{ // Nao decolar com transponder off
Wait();
cout <<"\nErro Transponder desativado..." << endl;
cout <<"Erro impossivel decolar..." << endl;
}
else if ( on_air == false)
{
cout <<"Procedimentos para decolagem..." << endl;
Distance();
Speed();
this->on_air = true;
system("cls");
cout <<"Acelerando Airplane..." << endl;
for ( int i = 1; i<=speed; i ++ )
{
Sleep(10);
cout << i << "km/h" << endl;
}
cout << "Airplane no ar!" << endl;
cout << "Tempo estimado para destino: " << distance/speed <<" horas" << endl;
Wait();
for ( int i = 1; i<=distance; i ++ )
{
Sleep(10);
cout <<"Distancia jah percorrida: "<< i << "km" << endl;
}
}
else
{
cout << "Airplane jah esta no ar!" << endl;
}
}
void Airplane::ChangeFlight(){
if ( on_air == false){
cout <<"Erro Airplane ainda em solo... " << endl;
}
else
{
cout << "Alterar velocidade: " << endl;
Speed();
cout << "Alterar Distancia: " << endl;
Distance();
cout << "Nova velocidade: " << speed << endl;
cout << "Nova distancia: " << distance << endl;
cout << "Tempo estimado para destino: " << distance/speed <<"horas" << endl;
}
}
void Airplane::Wait()const{
cout << "Aguarde";
for ( int i = 1; i<=30; i ++ ){
Sleep(20);
cout <<".";
}
}
void Airplane::getRadar(){
cout <<"Objetos no radar: "<< radar <<endl;
}
void Airplane::blackboxResgister(int day, int month, int year){
blackbox.setDay(day);
blackbox.setMonth(month);
blackbox.setYear(year);
cout <<"Ultima manutenção em: " << endl;
blackbox.print();
}
void Airplane::setPassenger(){
if ( freeseats ==0){
cout <<"No vacancy" << endl;
}
else
{
registro= new Passenger[freeseats];
string aux;
do {
cout << "Nome: "<< freeseats << endl;
getline( cin, aux);
registro[freeseats].setNome(aux);
freeseats--;
} while ( freeseats >= 0);
}
}
void Airplane::getPassenger(){
if ( freeseats == 6)
{
cout <<"Empty" << endl;
}
else
{
for ( this->freeseats = 6; freeseats >=0; freeseats -- ){
registro[freeseats].getNome();}
}
}
Airplane::~Airplane(){
cout <<"\nDestrutor chamado para Airplane..." << endl;
}