Group Members Reg No:: Section: Project Submitted To
Group Members Reg No:: Section: Project Submitted To
Section : B
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.
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.
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;
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;
}
};
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(){
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;
}
};
cout<<endl<<endl;
cout<<"please review your order"<<endl;
getname();
getaddress();
getvisa();
getflight();
getclas();
}
};
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;
}
};
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");
};
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;
}
};
void setfile(){//filehandling
ofstream ofile;
ofile.open("order.txt");
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;
}
};
};
main()
{
int a;char ch;
booking *ptr;
cout<<"welcome to the ticket n cargo booking
app"<<endl;
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;
}}