-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFlight.cpp
64 lines (58 loc) · 2.45 KB
/
Flight.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
#include "Flight.h"
Flight::Flight(string boarding, string destination, string deptime, string depdate, string arrtime, string flytime, string airline, int totalBseats, int totalEseats, int availableBseats, int availableEseats, int flightnumber, int cost)
:boarding{ boarding },
destination{ destination },
deptime{ deptime },
depdate{ depdate },
arrtime{ arrtime },
flytime{ flytime },
airline{ airline },
totalBseats{ totalBseats },
totalEseats{ totalEseats },
availableBseats{ availableBseats },
availableEseats{ availableEseats },
flightnumber{ newflightnumber },
cost{ cost } {
}
Flight::~Flight()
{
}
int Flight::newflightnumber = 100000;
string Flight::pass = "This is the password";
ostream& operator<<(ostream& os, Flight& f) {
os << f.boarding << endl;
os << f.destination << endl;
os << f.deptime << endl;
os << f.depdate << endl;
os << f.arrtime << endl;
os << f.flytime << endl;
os << f.airline << endl;
os << f.totalBseats << " " << f.totalEseats << " " << f.availableBseats << " " << f.availableEseats << " " << f.flightnumber << " " << f.cost << endl;
return os;
}
istream& operator>>(istream& is, Flight& f) {
is >> ws;
getline(is, f.boarding);
is >> ws;
getline(is, f.destination);
is >> ws;
getline(is, f.deptime);
is >> ws;
getline(is, f.depdate);
is >> ws;
getline(is, f.arrtime);
is >> ws;
getline(is, f.flytime);
is >> ws;
getline(is, f.airline);
is >> f.totalBseats >> f.totalEseats >> f.availableBseats >> f.availableEseats >> f.flightnumber >> f.cost;
return is;
}
void Flight::display() {
cout << "____________________________________________________________________________________________________________________________________________" << endl;
cout << "Flight number : " << flightnumber << endl;
cout << boarding << " to " << destination << " at " << deptime << " on " << depdate << ", arrives at destination at " << arrtime << ", after flying for " << flytime << " hours" << endl;
cout << availableBseats << " out of " << totalBseats << " Bussiness class seats available and " << availableEseats << " out of " << totalEseats << " Economic class seats available " << endl;
cout << "Airlines : " << airline << " Bussiness class Price: " << cost * 1.5 << " Economic class Price: " << cost << endl;
cout << "____________________________________________________________________________________________________________________________________________" << endl;
}