Notes
![]() ![]() Notes - notes.io |
#include <chrono>
#include <ctime>
#include"AirportLinkList.cpp"
#include "Flight.cpp"
#include "PlaneList.cpp"
#include "Customer.cpp"
#include "Airport.cpp"
#include "Plane.cpp"
#include "CustomerTree.cpp"
#include "Ticket.cpp"
#include "passengers.cpp"
#include "TicketList.cpp"
#include "FlightList.cpp"
using namespace std;
struct airport *a_head;
struct FlightList *f_head;
struct Passengers *p_root;
struct Customers *c_root;
struct plane *planeHead;
//Ticket *ticket;
struct ticketList *t_head;
struct ticketList *t_last;
int ticketNumber;
int customerId;
bool searchDestination(string country,airport *first)
{
airport *p=first;
while(p!=NULL)
{
if(p->a.getCountry()==country)
{
return true;
}
p=p->next;
}
return false;
}
void flightDisplay(string destination)
{
FlightList *flight=f_head;
while(flight!=NULL)
{
if(destination==flight->f.getDestination())
{
cout<<"flight details"<<endl;
}
}
}
void updateCustomer(Customer *passenger,FlightList *flight)
{
string s = date::format("%F %T",chrono::system_clock::now());
passenger.updateFlightNo(passenger.getNoOfFlights()+1);
airport *a=a_head;
int mile=0;
while(a!=NULL)
{
if(flight->f.getDestination()==a->a.getCountry())///change with airport name
{
mile=a->a.getMilesFromIslamabad();
break;
}
a=a-a>next;
}
passenger.updateMile(passenger.getMileTraveled()+mile);
}
void ticketReservation(int flightId,int &ticketNumber)
{
FlightList *flight=f_head;
while(flight!=NULL)
{
if(flightId==flight->f.getFlightNumber())
{
int planeId=flight->f.getPlaneId();
plane *p=planeHead;
while(p!=NULL)
{
if(planeId==p->p.getPlaneId())
{
int customerId;
cout<<"Enter Customer Id:"<<endl;
cin>>customerId;
Customer *passenger;
passenger=searchCustomers(customerId,c_root);
if(passenger)
{
cout<<"which class do you want to travel in(first,second):"<<endl;
string planeClass;
cin>>planeClass;
if(planeClass=="first")
{
int maxSeats=p->p.getFirstClassSeats();
int currentSeat=p->p.getFirstClass();
if(currentSeat>=maxSeats)
{
cout<<"seats full"<<endl;
// cout<<"do you want to enter in waiting list"<<endl;
return;
}
else
{
Ticket t=new Ticket(passenger->getId(),passenger->getName(),flightId,ticketNumber++,"first",flight->f.getFirstClassPrice(),s);
insertTicket(t_head,t_last,t);
updateCustomer(passenger,flight);
p->p.setFirstClass(p->p.getFirstClass+1);
}
}
}
else if(planeClass=="second")
{
int maxSeats=p->p.getSecondClassSeats();
int currentSeat=p->p.getSecondClass();
if(currentSeat>=maxSeats)
{
cout<<"seats full"<<endls;
// cout<<"do you want to enter in waiting list"<<endl;
return;
}
else
{
Ticket *t=new Ticket(passenger->getId(),passenger->getName(),id,ticketNumber++,"second",flight->f.getSecondClassPrice(),s);
updateCustomer(passenger,flight);
p->p.setSecondClass(p->p.getSecondClass+1);
}
}
else
{
cout<<"invalid flight Class"<<endl;
return;
}
}
}
}
flight=flight->next;
}
}
void cancelReservation(int flightNumber,int ticketNumber)
{
FlightList *flight=f_head;
while(flight!=NULL)
{
if(id==flight->f.getNumber())
{
planeList *p=planeHead;
while(p!=NULL)
{
if(flight->f.getPlaneId()==p->p.getPlaneId())
{
// Passengers *removePassenger;
//removePassenger=searchPassenger(passengerId,p_root);
ticketList *ticket=t_head;
int passengerId;
while(ticket!=NULL)
{
if(ticket->t.getTicketNumber()==ticketNumber)
{
passengerId=ticket->t.getCustomerId()
deleteTicket(t_head,t_last,ticket->t);////use ticket number back waiting queue///////////////////
}
}
DeletePassenger(p_root,passengerId);
}
}
}
flight=flight->next;
}
}
main()
{
cout<<"WELCOME TO ISLAMABAD INTERNATIONAL AIRPORT"<<endl;
int opt;
a_head=NULL;
f_head=NULL;
p_root=NULL;
c_root=NULL;
planeHead=NULL;
t_head=NULL;
t_last=NULL;
// ticket=new Ticket[300];
ticketNumber=1;
customerId=1;
do
{
cout<<"press 1 to book a ticket for flight"<<endl;
cout<<"press 2 to add a customer"<<endl;
cout<<"press 3 to add flight"<<endl;
cout<<"press 0 to exit"<<endl;
cin>>opt;
int choice;
switch(opt)
{
case 1:
{
cout<<"press 1 to search destination"<<endl;
cout<<"press 2 to reserve seat "<<endl;
cout<<"press 3 to cancel booked seat"<<endl;
cout<<"press 4 to change reservation"<<endl;
cin>>choice;
switch(choice)
{
case 1:
{
string destination;
cout<<"Enter your destination country:"<<endl;
cin>>destination;
bool found=searchDestination(destination,a_head);
if(found)
{
cout<<"destination found"<<endl;
flightDisplay(destination);
}
else
cout<<"destination not found"<<endl;
}
break;
case 2:
{
int flightId;
cout<<"Enter flight number to for reservation:"<<endl;
cin>>flightId;
ticketReservation(flightId,ticketNumber);
}
break;
case 3:
{
int ticketNumber;
int flightNumber;
cout<<"Enter flight number to for reservation:"<<endl;
cin>>flightNumber;
cout<<"Enter ticket number to for reservation:"<<endl;
cin>>ticketNumber;
cancelReservation(flightNumber,ticketNumber);
}
break;
case 4:
{
int ticketNumber;
int flightNumber;
int cancelFlight;
cout<<"Enter flight number to cancel reservation:"<<endl;
cin>>cancelFlight;
cout<<"Enter flight number to reserve seat in flight:"<endl
cin>>flightNumber;
cout<<"Enter ticket number to for reservation:"<<endl;
cin>>ticketNumber;
cancelReservation(cancelFlight,ticketNumber);
ticketReservation(flightNumber,t_head,ticketNumber);
}
break;
}
}
break;
case 2:
{
cout<<"press 1 to add customer"<<endl;
//cout<<"press 2 to update customer detail"<<endl;
cout<<"press 2 to delete customer"<<endl;
cout<<"press 3 to view customer profile"<<endl;
cin>>choice;
switch(choice)
{
case 1:
{
string name;
string phoneNO;
string dateOfBirth;
int noOfFlights;
int mileTraveled;
cout<<"Enter your name:"<<endl;
cin>>name;
cout<<"Enter your phone number:"<<endl;
cin>>phoneNo;
cout<<"Enter your date of birth:"<<endl;
cin>>dateOfBirth;
Customer c=new Customer(customerId,name,phoneNo,dateOfBirth,noOfFlights,mileTraveled);
insertCustomers(c_root,c);
}
break;
case 2:
{
int c_Id;
cout<<"Enter customer Id to be deleted:"<<endl;
cin>>c_Id;
deleteCustomer(c_root,id);
cout<<"Deleted successfully"<<endl;
}
break;
case 3:
{
int c_Id;
cout<<"Enter customer Id to view profile:"<<endl;
cin>>c_Id;
Customers *c=c_head;
while(c!=NULL)
{
if(c->c.getId()==c_Id)
{
cout<<"name"<<c->c.getName()<<endl;
cout<<"phone Number:"<<c->c.getNumber()<<endl;
cout<<"Date Of Birth:"<<c->c.getDateOfBirth()<<endl;
cout<<"NO Of Flights:"<<c->c.getNoOfFlights()<<endl;
cout<<" mileTraveled:"<<c->c.getMileTraveled()<<endl;
break;
}
else if(c_Id<c->c.getId())
{
c=c->left;
}
else
{
c=c->right;
}
}
}
break;
}
}
break;
/*case 3:
{
cout<<"press 1 to add flight"<<endl;
cout<<"press 2 to update flight"<<endl;
cout<<"press 3 to delete flight"<<endl;
cout<<"press 4 to view flights"<<endl;
}
break;*/
}
}
while(opt!=0);
}
![]() |
Notes is a web-based application for online taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000+ notes created and continuing...
With notes.io;
- * You can take a note from anywhere and any device with internet connection.
- * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
- * You can quickly share your contents without website, blog and e-mail.
- * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
- * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.
Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.
Easy: Notes.io doesn’t require installation. Just write and share note!
Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )
Free: Notes.io works for 14 years and has been free since the day it was started.
You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;
Email: [email protected]
Twitter: http://twitter.com/notesio
Instagram: http://instagram.com/notes.io
Facebook: http://facebook.com/notesio
Regards;
Notes.io Team