Assignment # I: Dated: 21 October.2020
Assignment # I: Dated: 21 October.2020
Code:
#include<iostream>
using namespace std;
class flight
{
public:
int airplaneNo;
string destination, departDate, departPlace, time, totalSeats, availableSeats;
void setData ()
{
cout << "Enter Air Plane Number:";
cin >> airplaneNo;
cout << "Enter depart Date:";
cin >> departDate;
cout << "Enter depart Place:";
cin >> departPlace;
cout << "Enter time:";
cin >> time;
cout << "Enter
Total seats:"; cin >>
totalSeats;
cout << "Enter available seats:";
cin >> availableSeats;
}
};
class ticket
{
public:
};
class booking
{
public:
int bookingID, bookingStatus;
booking ()
{
bookingStatus = 1;
}
};
class payment
{
public:
bool done;
};
class luggage
{
public:
int weight;
};
class passenger : public booking ,public ticket, public payment, public
luggage {
public:
int passport, airplaneNoPass;
string name, nic, age, gender;
};
int limit = 30;
int main ()
{
int z = 0, choice, i, tempID;
flight arr[10];
passenger obj1;
while (choice !=10)
{
cout << "Enter 1 to put flight data in:";
cout << "Enter 2 to book a ticket:";
cout << "Enter 10 to quit:";
cin >> choice;
if (choice == 1)
{
arr[z].setData ();
z++;
}
if (choice == 2)
{
cout << "Following are the flights\n";
for (i=0;i<z;i++)
{
arr[i].getData ();
}
cout << "Enter Air plance no to book a seat:";
cin >> tempID;
for (i=0;i<z;i++)
{
if (arr[i].airplaneNo == tempID)
{
if (arr[i].availableSeats > 0)
{
obj1.airplaneNoPass
= arr[i].airplaneNo;
arr[i].availableSeats --; }
}
}
}
}
}