Overview (This program is done in C++ language and i am personally using visual
ID: 3767752 • Letter: O
Question
Overview
(This program is done in C++ language and i am personally using visual studios 2013 however the IDE doesnt really matter as long as it will work on VS13)
This program is to support the client-side of an airline reservation system for airline reservation agents. The program does not manage user accounts, it only shows status of the flights. It allows the reservation agent to perform basic functions such as book and cancel reservations, display information such as boarding passes and seat assignments on the flight.
NOTE: All data for flights, passengers, etc. should be read from a file at the start of the program. The program should only save data back to file when given a command by the user and when the program is exiting.
Detailed Description
The system should allow a user to perform the following functions:
Book a new reservation
Cancel a reservation
Display boarding pass for a passenger
Display flight schedule (sorted by any field)
Display available cities (sorted by name or code)
List passengers on a given flight and seat assignments (sorted by name or seat)
The airline has two types of aircraft. The type A plane irst has 5 rows. Each row has seats A, B, C, and D arranged as the following (The aisle is indicated with an X):
X
The second ptype of plane has 5 rows with seats A, B, and C in the following configuration:
The airline flies between the following cities:
The flight schedule is the same every day of the week. The following table contains the flight information to be used for reservations:
Frequent Flyer points
Your system must make sure that a flight is not overbook, and if a flight is booked it should suggest other flights to the same destination. The boarding pass should include the flight details including the seat number and the number of frequent flyer miles that can be earned.
Input
The input is all done via interactive data entry. You may use menus, commands, etc. The interface is your choice.
Output
Output is done to the screen, but the program should also save all data between execution using one or more files. This means that when the system restarts, the reservations that have been made should reload. (Why does nobody answer this problem im very interested in the way to go about it?)
1A 1BX
1C 1D 2A 2B X 2C 2D 3A 3B X 3C 3D 4A 4B X 4C 4D 5A 5B X 5C 5DExplanation / Answer
#include<fstream.h>
#include<iostream.h>
#include<iomanip.h>
#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
#include<process.h>
#include<dos.h>
#include<string.h>
#include<graphics.h>
#include"c:irlineox.cpp"
#include"c:irlineinfo.cpp"
#include"c:irlinecircle.cpp"
class airline
{
char name[20];
char addr[30];
char email[20];
long int phone;
long int passno;
long int date;
char source[30];
char dest[30];
char dep[20];
char arrv[20];
int pword;
public:
void mainmenu();
void showmenu();
void highlight(int);
void highlight_modify(int);
void show_modify();
void reserve();
void display();
void cancel();
void modify();
void m_name();
void m_date();
void m_mode();
void cls();
}
ob;
ifstream fin;
ofstream fout;
int choice;
int size=sizeof(airline);
void line()
{
cout<<" ";
for(int i=0;i<80;i++)
cout<<"-";
cout<<" ";
}
void airline::mainmenu()
{
char ch;
int count=1;
textbackground(0);
textcolor(15);
clrscr();
ob.showmenu();
highlight(1);
_setcursortype(_NOCURSOR);
while(1)
{
ch=getch();
switch(ch)
{
case 80:
count+=1;
if(count==8) count=1;
break;
case 72:
count-=1;
if(count==0) count=7;
break;
}
showmenu();
ob.highlight(count);
if(ch==' ')
{
ob.cls();
if(count==7)exit(0);
if(count==1)
{
clrscr();
info();
ob.mainmenu();
}
if(count==2) ob.reserve();
if(count==3)
{
clrscr();
ob.display();
getch();
}
if(count==4)ob.modify();
if(count==5)
{
ob.cancel();
getch();
}
if(count==6)
{
clrscr();
about();
}
}
}
}
void airline::showmenu()
{
int k=0;
char *ch[]={"PLANE_INFO.","RESERVATION.","DISPLAY.","MODIFY.","CANCELATION.","EXIT."};
textcolor(7);
int i;
box(18,3,60,7);
gotoxy(30,5);
printf(" ==== MAIN MENU ====");
textbackground(0);
box(18,9,60,25);
for(i=0;i<7;i++)
{
gotoxy(32,11+k);
cprintf("%s",ch[i]);
k+=2;
}
}
void airline::highlight(int item)
{
textcolor(WHITE);
textbackground(2);
switch(item)
{
case 1:
gotoxy(32,11);
cprintf("PLANE_INFO.");
break;
case 2:
gotoxy(32,13);
cprintf("RESERVATION.");
break;
case 3:
gotoxy(32,15);
cprintf("DISPLAY.");
break;
case 4:
gotoxy(32,17);
cprintf("MODIFY.");
break;
case 5:
gotoxy(32,19);
cprintf("CANCELATION.");
break;
case 6:
gotoxy(32,23);
cprintf("EXIT.");
break;
}
}
void airline::cls()
{
textcolor(15);
textbackground(0);
for(int c=1;c<=79;c++)
for(int r=1;r<=24;r++)
{
gotoxy(c,r);
cprintf(" ");
}
}
void airline::modify()
{
char ch;
int count=1;
textbackground(0);
textcolor(15);
clrscr();
ob.show_modify();
highlight_modify(1);
while(1)
{
ch=getch();
switch(ch)
{
case 80:
count++;
if(count==5) count=1;
break;
case 72:
count--;
if(count==0) count=4;
break;
}
ob.show_modify();
ob.highlight_modify(count);
if(ch==' ')
{
cls();
if(count==4)ob.mainmenu();
if(count==1)m_name();
if(count==2)m_date();
if(count==3)m_mode();
}
}
}
void airline::show_modify()
{
int k=0;
char *ch[]={" NAME."," DATE."," MODE."," >>>BACK<<<"};
textcolor(7);
int i;
box(29,4,49,6);
gotoxy(30,5);
printf("====MODIFY MENU====");
textbackground(0);
box(29,7,49,20);
for(i=0;i<4;i++)
{
gotoxy(30,9+k);
//outtextxy(30,9+k,ch[i]);
cprintf("%s",ch[i]);
k+=2;
}
}
void airline::highlight_modify(int item)
{
textcolor(WHITE);
textbackground(2);
switch(item)
{
case 1:
gotoxy(33,9);
cprintf("NAME.");
break;
case 2:
gotoxy(33,11);
cprintf("DATE.");
break;
case 3:
gotoxy(33,13);
cprintf("MODE.");
break;
case 4:
gotoxy(33,15);
cprintf(">>>BACK<<<.");
break;
}
}
void airline::m_name()
{
int login,flg=0;
FILE *fp;
fp=fopen("xxxx.txt","r+");
cout<<" Enter your password : ";
cin>>login;
while(fread(&ob,sizeof(ob),1,fp)==1)
{
if(login==pword)
{
flg=1;
clrscr();
box(5,2,75,15);
gotoxy(28,2);
cout<<" ++ Search Results ++ ";
gotoxy(8,5);
cout<<" Resv ID : "<<pword;
gotoxy(8,6);
cout<<" Name : "<<name;
gotoxy(8,10);
cout<<" Enter New Name : ";
gets(name);
fseek(fp, ftell(fp) - sizeof(ob),0);
fwrite(&ob, sizeof(ob), 1, fp);
}
else
{
flg=0;
}
if(flg==0)
{
clrscr();
gotoxy(28,13);
cout<<" +++ Record Not Found +++ ";
getch();
}
else
{
gotoxy(28,24);
cout<<" +++ Database Updated +++ ";
getch();
}
fclose(fp);
ob.mainmenu();
}
void airline::m_date()
{
int login,flg=0;
FILE *fp;
fp=fopen("xxxx.txt","r+");
cout<<" Enter your password : ";
cin>>login;
while(fread(&ob,sizeof(ob),1,fp)==1)
{
if(login==pword)
{
flg=1;
clrscr();
box(5,2,75,15);
gotoxy(28,2);
cout<<" ++ Search Results ++ ";
gotoxy(8,5);
cout<<" Resv ID : "<<pword;
gotoxy(8,6);
cout<<" Name : "<<date;
gotoxy(8,10);
cout<<" Enter New Date : ";
cin>>date;
fseek(fp, ftell(fp) - sizeof(ob),0);
fwrite(&ob, sizeof(ob), 1, fp);
}
else
{
flg=0;
}
}
if(flg==0)
{
clrscr();
gotoxy(28,13);
cout<<" +++ Record Not Found +++ ";
getch();
}
else
{
gotoxy(28,24);
cout<<" +++ Database Updated +++ ";
getch();
}
fclose(fp);
ob.mainmenu();
}
void airline::m_mode()
{
int login,flg=0;
int mode,plno;
char pname[10];
FILE *fp;
fp=fopen("xxxx.txt","r+");
cout<<" Enter your password : ";
cin>>login;
while(fread(&ob,sizeof(ob),1,fp)==1)
{
if(login==pword)
{
flg=1;
cout<<" 1:Domestic 2:International Enter the mode:";
cin>>mode;
if(mode==1)
{
cout<<" Enter the plane 1 , 2 , 3 , 4 , 5 - ";
cin>>plno;
switch(plno)
{
case 1: strcpy(pname,"aado1");
strcpy(source,"Chennai");
strcpy(dest,"Mumbai");
strcpy(dep,"10:00");
strcpy(arrv,"11:00");
break;
case 2: strcpy(pname,"aado2");
strcpy(source,"Mumbai");
strcpy(dest,"Kolkata");
strcpy(dep,"12:00");
strcpy(arrv,"13:15");
break;
case 3: strcpy(pname,"aado3");
strcpy(source,"Kolkata");
strcpy(dest,"Chennai");
strcpy(dep,"17:00");
strcpy(arrv,"18:00");
break;
case 4: strcpy(pname,"aado4");
strcpy(source,"Delhi");
strcpy(dest,"Mumbai");
strcpy(dep,"10:00");
strcpy(arrv,"13:00");
break;
case 5: strcpy(pname,"aado5");
strcpy(source,"Chandighar");
strcpy(dest,"Delhi");
strcpy(dep,"15:00");
strcpy(arrv,"12:00");
break;
}
}
else
if(mode==2)
{
cout<<" Enter the plane 1 , 2 , 3 , 4 , 5 - ";
cin>>plno;
switch(plno)
{
case 1: strcpy(pname,"aai01");
strcpy(source,"Mumbai");
strcpy(dest,"London");
strcpy(dep,"00:30");
strcpy(arrv,"10:30");
break;
case 2: strcpy(pname,"aai02");
strcpy(source,"Delhi");
strcpy(dest,"Paris");
strcpy(dep,"03:20");
strcpy(arrv,"13:20");
break;
case 3: strcpy(pname,"aaio3");
strcpy(source,"Chennai");
strcpy(dest,"Colombo");
strcpy(dep,"19:30");
strcpy(arrv,"20:30");
break;
case 4: strcpy(pname,"aaio4");
strcpy(source,"Patna");
strcpy(dest,"U.S.A");
strcpy(dep,"10:30");
strcpy(arrv,"23:30");
break;
case 5: strcpy(pname,"aaio5");
strcpy(source,"Chandighar");
strcpy(dest,"Austaliya");
strcpy(dep,"15:30");
strcpy(arrv,"12:30");
break;
}
}
fseek(fp, ftell(fp) - sizeof(ob),0);
fwrite(&ob, sizeof(ob), 1, fp);
}
else
{
flg=0;
}
}
if(flg==0)
{
clrscr();
gotoxy(28,13);
cout<<" +++ Record Not Found +++ ";
getch();
}
else
{
clrscr();
gotoxy(28,24);
cout<<" +++ Database Updated +++ ";
getch();
}
fclose(fp);
ob.mainmenu();
}
void main()
{
fout.close();
circle();
ob.mainmenu();
getch();
}
void airline::reserve()
{
int mode,plno;
char pname[10];
clrscr();
fout.open("xxxx.txt",ios::app);
cout<<" Enter passengers details : ";
cout<<" Name - ";
gets(name);
cout<<" Address - ";
gets(addr);
cout<<" E-Mail ID - ";
gets(email);
cout<<" Telephone no - ";
cin>>phone;
cout<<" Enter the date of travelling : ";
cin>>date;
line();
cout<<" 1:Domestic 2:International Enter the mode:";
cin>>mode;
if(mode==1)
{
cout<<" Enter the plane 1 , 2 , 3 , 4 , 5 - ";
cin>>plno;
switch(plno)
{
case 1: strcpy(pname,"aado1");
strcpy(source,"Chennai");
strcpy(dest,"Mumbai");
strcpy(dep,"10:00");
strcpy(arrv,"11:00");
break;
case 2: strcpy(pname,"aado2");
strcpy(source,"Mumbai");
strcpy(dest,"Kolkata");
strcpy(dep,"12:00");
strcpy(arrv,"13:15");
break;
case 3: strcpy(pname,"aado3");
strcpy(source,"Kolkata");
strcpy(dest,"Chennai");
strcpy(dep,"17:00");
strcpy(arrv,"18:00");
break;
case 4: strcpy(pname,"aado4");
strcpy(source,"Delhi");
strcpy(dest,"Mumbai");
strcpy(dep,"10:00");
strcpy(arrv,"13:00");
break;
case 5: strcpy(pname,"aado5");
strcpy(source,"Chandighar");
strcpy(dest,"Delhi");
strcpy(dep,"15:00");
strcpy(arrv,"12:00");
break;
}
}
else
if(mode==2)
{
cout<<" Enter the plane 1 , 2 , 3 , 4 , 5 - ";
cin>>plno;
switch(plno)
{
case 1: strcpy(pname,"aai01");
strcpy(source,"Mumbai");
strcpy(dest,"London");
strcpy(dep,"00:30");
strcpy(arrv,"10:30");
break;
case 2: strcpy(pname,"aai02");
strcpy(source,"Delhi");
strcpy(dest,"Paris");
strcpy(dep,"03:20");
strcpy(arrv,"13:20");
break;
case 3: strcpy(pname,"aaio3");
strcpy(source,"Chennai");
strcpy(dest,"Colombo");
strcpy(dep,"19:30");
strcpy(arrv,"20:30");
break;
case 4: strcpy(pname,"aaio4");
strcpy(source,"Patna");
strcpy(dest,"U.S.A");
strcpy(dep,"10:30");
strcpy(arrv,"23:30");
break;
case 5: strcpy(pname,"aaio5");
strcpy(source,"Chandighar");
strcpy(dest,"Austaliya");
strcpy(dep,"15:30");
strcpy(arrv,"12:30");
break;
}
}
randomize();
pword=random(1000);
cout<<" PASSWORD "<<pword;
getch();
fout.write((char*)&ob,size);
fout.close();
line();
ob.mainmenu();
}
void airline::display()
{
cout<<" ++++ Passenger Reports ++++ ";
line();
cout<<"RESNO"<<setw(12)<<"NAME"<<setw(12) ;
cout<<"ADDRESS"<<setw(12)<<"SOURCE";
cout<<setw(16)<<"DESTINATION"<<setw(12)<<"DATE";
fin.open("xxxx.txt");
line();
while(fin.read((char*)&ob,size))
{
cout<<pword<<setw(12)<<name;
cout<<setw(12)<<addr<<setw(12);
cout<<source<<setw(16)<<dest<<setw(14)<<date<<" ";
}
line();
fin.close();
getche();
ob.mainmenu();
}
void airline::cancel()
{
int login,p=0;
fin.open("xxxx.txt");
fout.open("temp.txt");
cout<<" Enter your password : ";
cin>>login;
while(fin)
{
if(login==pword)
p=1;
if(login!=pword)
fout.write((char*)&ob,size);
fin.read((char*)&ob,size);
}
fin.close();
fout.close();
remove("xxxx.txt");
rename("temp.txt","xxxx.txt");
clrscr();
if(p==0)
cout<<" No match found";
else
cout<<" Reservation cancelled";
getch();
ob.mainmenu();
}
getch();
mainmenu();
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.