-
Notifications
You must be signed in to change notification settings - Fork 19
Expand file tree
/
Copy pathProblem 04.cpp
More file actions
75 lines (62 loc) · 1.75 KB
/
Problem 04.cpp
File metadata and controls
75 lines (62 loc) · 1.75 KB
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
#include<iostream>
using namespace std;
class Flight
{
static int totalPlanes;
int flightNum;
int capacity;
string destination;
int fuel;
public:
int getTotalPlanes() {return totalPlanes;}
void setFlightNum(int a) {flightNum = a;}
int getFlightNum() {return flightNum;}
void setCapacity(int a) {capacity = a;}
int getCapacity() {return capacity;}
void setDestination(string a) {destination = a;}
string getDestination() {return destination;}
void setDistance(int a)
{
if (a/4 > 2000) cout<<"\nWarning! Fuel required exceeds capacity! Distance not set!"<<endl;
else fuel = a/4;
}
int getFuelRequired() {return fuel;}
Flight() : flightNum(totalPlanes+1), capacity(0), destination(""), fuel(0) {totalPlanes++;}
};
int Flight :: totalPlanes(0);
class Airline
{
Flight f[10];
public:
void setInfo(int a)
{
if (a>10) cout<<"No such flight exists!"<<endl;
else
{
int tempInt;
string tempString;
cout<<"\nEnter Passenger Capacity: ";
cin>>tempInt;
f[a-1].setCapacity(tempInt);
cout<<"\nEnter Destination: ";
cin>>tempString;
f[a-1].setDestination(tempString);
cout<<"\nEnter Distance from Dhaka: ";
cin>>tempInt;
f[a-1].setDistance(tempInt);
}
}
void showInfo()
{
for (int i=0; i<f[0].getTotalPlanes(); i++)
{
cout<<"\nFlight Number: "<<f[i].getFlightNum()<<"\nPassenger Capacity: "<<f[i].getCapacity()<<"\nDestination: "<<f[i].getDestination()<<"\nFuel Required: "<<f[i].getFuelRequired()<<endl;
}
}
};
int main()
{
Airline a;
a.setInfo(1);
a.showInfo();
}