0% found this document useful (0 votes)
30 views

Group Members Reg No:: Section: Project Submitted To

The document describes a booking application project with the following key details: - The project allows customers to book plane, train, bus tickets and cargo service through classes derived from a superclass called Booking. - The Plane, Train, Bus and Cargo classes inherit from Booking and have additional methods to collect customer details specific to each mode of transport. - A main method allows customers to select the class of their choice and book tickets by creating objects and calling methods on the selected class. File handling is used to store booking details.

Uploaded by

shabih
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
30 views

Group Members Reg No:: Section: Project Submitted To

The document describes a booking application project with the following key details: - The project allows customers to book plane, train, bus tickets and cargo service through classes derived from a superclass called Booking. - The Plane, Train, Bus and Cargo classes inherit from Booking and have additional methods to collect customer details specific to each mode of transport. - A main method allows customers to select the class of their choice and book tickets by creating objects and calling methods on the selected class. File handling is used to store booking details.

Uploaded by

shabih
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 34

Group Members Reg no:

Hafiz Ali Qureshi Bcs02163407

Muhammad Ahmad Saeed Bcs02163111

Numan Anjum Bcs02163078

Umar Razzaq Bcs02163146

Taha Zahid Bcs02163107

Section : B

Project Submitted to: Sir Azeem Qureshi


Introduction
 Project is about Booking ticket app through which client can buy plane, train and bus
ticket and cargo service also.

Super class by name Booking


 It contains all data members like name, cell number, address etc.
 All the members will be assign value through setter and getters.

Plane class drive from booking class

 In this all the data members of the booking class will be assign values by calling their function
of setters.
 Ask the user to enter the country name you want to buy ticket.
 Enter the airline name containing different flight rates.
 Enter the class like economic for bus.
 Ask him to send a car of his choice to pick him from his house to airport.
 Ask him to enter visa card number and pin to buy ticket.
 A pure virtual function collects all the amount and display to the user.
 Ask him to check his order if ok then store the data in a file by using file handling.

Train class drive from booking class

 In this all the data members of the booking class will be assign values by calling their function
of setters.
 Ask the user to enter the city name you want to buy ticket.
 Enter the train service name containing different rates.
 Enter the class like economic for business.
 Ask him to send a car of his choice to pick him from his house to railway station.
 A pure virtual function collects all the amount and display to the user.
 Ask him to enter visa card number and pin to buy ticket.
 Ask him to check his order if ok then store the data in a file by using file handling.
Bus class drive from booking class

 In this all the data members of the booking class will be assign values by calling their function
of setters.
 Ask the user to enter the city name you want to buy ticket.
 Enter the bus name like van or coach.
 Enter the bus type ac or simple containing different rates.
 Ask him to send a car of his choice to pick him from his house to bus terminal.
 Ask him to enter visa card number and pin to buy ticket.
 A pure virtual function Collect all the amount and display to the user.
 Ask him to check his order if ok then store the data in a file by using file handling.

Cargo class drive from booking class

 In this all the data members of the booking class will be assign values by calling their function
of setters.
 Ask the user to enter the country name you want to send cargo.
 Enter the cargo service you like by air or ship.
 Display rates of both.
 Ask him to enter visa card number and pin to buy cargo service.
 A pure virtual function collects all the amount and display to the user.
 Ask him to check his order if ok then store the data in a file by using file handling.

Main
 In the main user enter his choice he want to buy ticket
 Create the object of user choice class
 Call that class through constructor
 Create pointer type of booking class
 Pointer will point towards pure virtual to calculate all amount of the user’s choice class
Code of project

#include<iostream>
#include<fstream>
#include<string.h>
using namespace std;

class booking{//super class


public:
char name[30];//data members
char address[50];
double visa;
int code;
public:
void setname()
{
cout<<"enter your name="<<endl;
cin>>name;
}

void getname()
{
cout<<"Your name is="<<name<<endl;
}

void setaddress()
{
cout<<"enter your address ="<<endl;
cin>>address;
}

void getaddress(){
cout<<"your address is="<<address<<endl;
}
void setvisa(){
cout<<"enter your cerdit card
number"<<endl;
cin>>visa;}
void getvisa(){
cout<<"your ticket is book on card
number="<<visa<<endl;
}

void setcode(){
cout<<"enter your pin"<<endl;
cin>>code;
}

virtual void info()=0;//pure virtual function


by concept of polymorphism

};
class Car{
public:
char car[30];
public:
void setcar()

{
cout<<"enter the car name we sent to pick
you City or Corolla"<<endl;
cin>>car;
}
void getcar()
{
cout<<"we send "<<car<<" car to pick you
at your address"<<endl;
}
};

class planerate{
public:
char flight[30];
char clas[30];
public:
void setflight(){

cout<<"PIA flight is very cheap"<<endl;


cout<<"AirBlue is expensive then PIA"<<endl;
cout<<"Emirates and Qatar Airlines are very
expensive but are best airlines"<<endl;
cout<<"Enter the flight name you want to
travel"<<endl;
cin>>flight;

void getflight(){
cout<<"You book a flight of "<<flight<<"
airlines"<<endl;
}

void setclas(){
cout<<"You want to buy economic class or
bussiness class ticket"<<endl;
cout<<"Economic class is affortable"<<endl;
cout<<"bussiness is expensive then economic
class"<<endl;
cin>>clas;
}

void getclas(){
cout<<"YOu book "<<clas<<" class
ticket"<<endl;
}

};

class plane:public booking,public Car,public


planerate{//multiple inheritance
public:
char country[30];
plane()//constructor
{
setname();
setaddress();
cout<<"enter the country name you want
to buy ticket"<<endl;
cin>>country;
setflight();
setclas();
setvisa();
setcode();
setcar();
}
voidinfo()//polymorphism
{

cout<<endl<<endl;
cout<<"please review your order"<<endl;
getname();
getaddress();
getvisa();
getflight();
getclas();

cout<<"your plane ticket is


booked"<<endl;
cout<<"your ticket is for travel to
"<<country<<endl;
getcar();
}
void setfile(){
ofstream ofile;
ofile.open("order.txt");

ofile<<"your name is="<<name<<endl;


ofile<<"your address is="<<address<<endl;
ofile<<"your ticket is book visa num
is="<<visa<<endl;
ofile<<"your filght is by "<<flight<<"
airlines"<<endl;
ofile<<"you book a "<<clas<<"
class"<<endl;

ofile<<"your plane ticket is


booked"<<endl;
ofile<<"your ticket is for travel to
"<<country<<endl;
ofile<<"we send"<<car<<"car to pick you
on your location"<<endl;
ofile.close();

}
};
class traintype{
public:
char type[10];
char trainname[10];
void settype()
{
cout<<"enter the train type bussiness or
economy"<<endl;
cout<<"economy class is cheaper"<<endl;
cout<<"bussiness class is best for
travel"<<endl;
cin>>type;
}
void gettype()
{
cout<<"you book a "<<type<<" class ticket
for train"<<endl;
}
void settrainname(){
cout<<"enter train name karakarm or
other"<<endl;
cin>>trainname;
}

void gettrainname(){
cout<<"you book train ticket of
"<<trainname<<" railway"<<endl;
}
};

class train:public booking,public traintype{//multiple


inheritance

char city[30];
public:

train()//constructor
{
setname();
setaddress();
cout<<"enter the city name you want to
buy ticket"<<endl;
cin>>city;
settype();
settrainname();
setvisa();
setcode();
}

void info()//polymorphism
{cout<<endl<<endl;
cout<<"please review your order "<<endl;
getname();
getaddress();
gettype();
gettrainname();
getvisa();
cout<<"your train ticket is booked"<<endl;
cout<<"your ticket is for travel to
"<<city<<endl;
}
void setfile(){//filehandling
ofstream ofile;
ofile.open("order.txt");

ofile<<"your name is="<<name<<endl;


ofile<<"your address is="<<address<<endl;
ofile<<"your ticket is book visa num
is="<<visa<<endl;
ofile<<"you book a "<<type<<" class
train"<<endl;
ofile<<"you book a "<<trainname<<"
railway ticket"<<endl;
ofile<<"your train ticket is booked"<<endl;
ofile<<"your ticket is for travel to
"<<city<<endl;
ofile.close();
}

};

class bustype{
public:
char type[10];
char busname[10];
void settype()
{
cout<<"enter the bus type ac or
general"<<endl;
cout<<"general class is cheaper"<<endl;
cout<<"air contioned bus is best for
travel"<<endl;
cin>>type;
}

void gettype()
{
cout<<"you book a "<<type<<" bus ticket
for travel"<<endl;
}

void setbusname(){
cout<<"enter bus name hiace or
coach"<<endl;
cin>>busname;
}
void getbusname(){
cout<<"you book a bus ticket of
"<<busname<<" bus"<<endl;
}
};

class bus:public booking,public bustype{//multiple


inheritance drive from super class
char city[30];
public:
bus(){
setname();
setaddress();
cout<<"enter the city name you want to
buy ticket"<<endl;
cin>>city;
settype();
setbusname();
setvisa();
setcode();
}
void info()//polymorphism
{
cout<<endl<<endl;
cout<<"please review your order"<<endl;
getname();
getaddress();
gettype();
getbusname();
getvisa();

cout<<"your bus ticket is booked"<<endl;


cout<<"your ticket is for travel to
"<<city<<endl;
}

void setfile(){//filehandling
ofstream ofile;
ofile.open("order.txt");

ofile<<"your name is="<<name<<endl;


ofile<<"your address is="<<address<<endl;
ofile<<"your ticket is book visa num
is="<<visa<<endl;
ofile<<"you book a "<<type<<" bus
ticket"<<endl;
ofile<<"you book a "<<busname<<" bus
ticket"<<endl;
ofile<<"your bus ticket is booked"<<endl;
ofile<<"your ticket is for travel to
"<<city<<endl;
ofile.close();
}
};

class cargotype{
public:
char type[10];
void settype(){
cout<<"enter your choice to send cargo by
ship or by air"<<endl;
cout<<"shipping is cheaper"<<endl;
cout<<"by air is fast processing"<<endl;
cin>>type;
}
void gettype(){
cout<<"you select "<<type<<"service for
cargo"<<endl;
}
};

class cargo:public booking,public cargotype{//multiple


inheritance drive from booking n cargotype class
char city[30];
public:
cargo(){//constructor
setname();
setaddress();
cout<<"enter the city or country name you
want to send cargo"<<endl;
cin>>city;
settype();
setvisa();
setcode();
}
void info()//polymorphism
{
cout<<endl<<endl;
cout<<"review your order"<<endl;
getname();
getaddress();
getvisa();
gettype();
cout<<"your cargo is booked"<<endl;
cout<<"your cargo will be send to
"<<city<<endl;
}
void setfile(){//filehandilng
ofstream ofile;
ofile.open("order.txt");
ofile<<"your name is="<<name<<endl;
ofile<<"your address is="<<address<<endl;
ofile<<"you book cargo by visa num
is="<<visa<<endl;
ofile<<"you book cargo service by
"<<type<<endl;

ofile<<"your cargo is booked"<<endl;


ofile<<"your cargo will be send to
"<<city<<endl;
ofile.close();

};

main()
{
int a;char ch;

booking *ptr;
cout<<"welcome to the ticket n cargo booking
app"<<endl;

while(ch!='k')//while loop run untill user enter k


{
cout<<"press 1 for airplane ticket"<<endl;
cout<<"press 2 for train ticket"<<endl;
cout<<"press 3 for bus ticket"<<endl;
cout<<"press 4 for cargo booking"<<endl;
cin>>a;

if(a==1)//check
{
plane p;//calling constructor of plane
ptr=&p;//set pointer to the plane
ptr->info();//get value by using virtual function
p.setfile();//call filehandling funtion of plane class
cout<<endl<<endl;
cout<<"please confirm your order if ok then press k
otherwise press any key for again order"<<endl;
cin>>ch;
}

else if(a==2)//check
{
train t;//calling constructor of train
ptr=&t;//set pointer to the train
ptr->info();//get value by using virtual function
t.setfile();//call filehandling funtion of train class
cout<<"please confirm your order if ok then press k
otherwise press any key for again order"<<endl;
cin>>ch;
}

else if(a==3)//check
{
bus b;//calling constructor of bus
ptr=&b;//set pointer to the bus
ptr->info();//get value by using virtual function
b.setfile();//call filehandling funtion of train
class
cout<<"please confirm your order if ok then
press k otherwise press any key for again order"<<endl;
cin>>ch;
}

else if(a==4)//check
{
cargo c;//calling constructor of plane
ptr=&c;//set pointer to the cargo
ptr->info();//get value by using virtual function
c.setfile();//call filehandling funtion of cargo
class
cout<<"please confirm your order if ok then
press k otherwise press any key for again order"<<endl;
cin>>ch;
}

else{//wrong input
cout<<"you choose wrong option press n
for again order"<<endl;
cin>>ch;
}}

cout<<"thank you for placing order


:-)"<<endl;//program end
}
Outputs:

You might also like