You are on page 1of 23

/* PROJECT:: AIR TICKET RESERVATION SYSTEM*/

//header files
#include <iostream.h>
#include <graphics.h>
#include <fstream.h>
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include <ctype.h>
#include <conio.h>
#include <dos.h>

//class to draw lines,boxes for providing proper user interface


class draw
{
public :
void line_hor(int, int, int, char) ;
void line_ver(int, int, int, char) ;
void box(int,int,int,int,char) ;
};

//class to include details of air ticket


class ticket
{
private :
void add_record(char[10], char[15], char[15], int, int) ;
protected :
char fltno[10], from[15], to[15] ;
int ecofare, exefare ;
public :

void addition(void) ;
void enquiry(void) ;
char *flightno(int) ;
};

//class to control the functions for passenger


class passenger
{
protected :
char Class, name[26], address[36], sex ;
int slno, age, ticketno ;
public :
void add_record(int, int, char[26], char[36], int, char, char) ;
void delete_ticket(int) ;
int delete_flight(int) ;
void list(void) ;
int last_ticketno(void) ;
int seats(int) ;
int found(int) ;
char *Name(int) ;
};

//this is derived class which controls functions related to


//reservation,cancellation... etc.
class reserve : public ticket, public passenger
{
public :
void reservation(void) ;
void cancellation(void) ;
void dislpay_ticket(void) ;
void delete_all(void) ;
};

//function to draw horizontal line


void draw :: line_hor(int column1, int column2, int row, char c)
{
for ( ; column1<=column2; column1++ )
{
gotoxy(column1,row) ;
cout <<c ;
}
}

//function to draw vertical line


void draw :: line_ver(int row1, int row2, int column, char c)
{
for ( ; row1<=row2; row1++ )
{
gotoxy(column,row1) ;
cout <<c ;
}
}

//function to draw box


void draw :: box(int column1, int row1, int column2, int row2, char c)
{
char ch=218 ;
char c1, c2, c3, c4 ;
char l1=196, l2=179 ;
if (c == ch)
{
c1=218 ; //218->Ú
c2=191 ; //191->¿
c3=192 ; //192->À
c4=217 ; //217->Ù
l1 = 196 ; //196->Ä
l2 = 179 ; // 179->³
}
else
{
c1=c ;
c2=c ;
c3=c ;
c4=c ;
l1 = c ;
l2 = c ;
}
gotoxy(column1,row1) ;
cout <<c1 ;
gotoxy(column2,row1) ;
cout <<c2 ;
gotoxy(column1,row2) ;
cout <<c3 ;
gotoxy(column2,row2) ;
cout <<c4 ;
column1++ ;
column2-- ;
line_hor(column1,column2,row1,l1) ;
line_hor(column1,column2,row2,l1) ;
column1-- ;
column2++ ;
row1++ ;
row2-- ;
line_ver(row1,row2,column1,l2) ;
line_ver(row1,row2,column2,l2) ;
}

//function to add given data in the ticket file(varun1.txt)


void ticket :: add_record(char t_fltno[10], char t_from[15], char t_to[15], int t_ecofare,
int t_exefare)
{
fstream file ;
file.open("varun1.txt", ios::app) ;
strcpy(fltno,t_fltno) ;
strcpy(from,t_from);
strcpy(to,t_to) ;
ecofare = t_ecofare ;
exefare = t_exefare ;
file.write((char *) this, sizeof(ticket)) ;
file.close() ;
}

//function which returns the flight no. for a given s.no


char *ticket :: flightno(int sno)
{
fstream file ;
file.open("varun1.txt", ios::in) ;
int count=1 ;
while (file.read((char *) this, sizeof(ticket)))
{
if (sno == count)
break ;
count++ ;
}
file.close() ;
return fltno ;
}

//function to add flights


void ticket :: addition(void)
{
fstream file ;
file.open("varun1.txt", ios::in) ;
if (!file.fail())
return ;
file.close() ;
add_record("V146","DELHI ","MUMBAI ",5500,5700) ;
add_record("V146","MUMBAI ","DELHI ",5500,5700) ;
add_record("V156","DELHI ","CALCUTTA",5700,5900) ;
add_record("V156","CALCUTTA","DELHI ",5700,5900) ;
add_record("V166","DELHI ","CHENNAI ",5100,5300) ;
add_record("V166","CHENNAI ","DELHI ",5100,5300) ;
add_record("V176","MUMBHAI ","CALCUTTA",5900,5100) ;
add_record("V176","CALCUTTA","MUMBAI ",5900,5100) ;
add_record("V186","MUMBAI ","CHENNAI ",5800,5000) ;
add_record("V186","CHENNAI ","MUMBAI ",5800,5000) ;
add_record("V196","CALCUTTA","CHENNAI ",5600,5800) ;
add_record("V197","CHENNAI ","CALCUTTA",5600,5800) ;
}

//function which displays list of flights


void ticket :: enquiry(void)
{
clrscr() ;
fstream file ;
passenger p;
file.open("varun1.txt", ios::in) ;
draw d ;
d.box(1,2,75,22,218) ;
d.line_hor(2,74,4,196) ;
d.line_hor(2,74,6,196) ;
d.line_hor(2,74,22,196) ;
textcolor(YELLOW+BLINK) ;
gotoxy(30,3) ;
cprintf("LIST OF THE FLIGHTS") ;
textcolor(LIGHTGRAY) ;
textcolor(GREEN) ; textbackground(RED) ;
for (int i=2; i<=73; i++)
{
gotoxy(i,5) ;
cprintf(" ") ;
}
gotoxy(2,4) ;
cprintf(" Sno. FLIGHT NO. FROM TO ECONOMIC EXECUTIVE
SEATS") ;
cprintf(" FARE FARE AVAILABLE ");
textcolor(GREEN) ; textbackground(BLACK) ;
int row=7, sno=1 ;
while (file.read((char *) this, sizeof(ticket)))
{
gotoxy(4,row) ;
cout <<sno ;
gotoxy(9,row) ;
cout <<fltno ;
gotoxy(20,row) ;
cout <<from ;
gotoxy(34,row) ;
cout <<to ;
gotoxy(46,row) ;
cout <<ecofare ;
gotoxy(60,row) ;
cout <<exefare ;
gotoxy(68,row);
cout<<(250-p.seats(sno));
row++ ;
sno++ ;
}
file.close() ;
}

//function to reserve ticket for the passenger


void reserve :: reservation(void)
{
clrscr() ;
enquiry() ;
char t1[5], pclass, pname[26], paddress[36], psex, pfltno[10] ;
int t2, valid, page, tno, sno ;
passenger p ;
tno = p.last_ticketno() + 1 ;
do
{
valid = 1 ;
gotoxy(3,23) ;
cout <<" ";
gotoxy(3,23) ;
cout <<"PRESS <ENTER> TO EXIT" ;
gotoxy(3,20) ;
cout <<" ";
gotoxy(3,20) ;
cout <<"Enter Sno. of the FLIGHT : " ;
gets(t1) ;
t2 = atoi(t1) ;
sno = t2 ;
if (strlen(t1) == 0)
return ;
if (sno < 1 || sno > 12)
{
valid = 0 ;
gotoxy(3,23) ;
cout <<" ";
gotoxy(3,23) ;
cout <<"\nENTER CORRECTLY" ;
getch() ;
}
} while (!valid) ;
int i=1 ;
fstream file ;
file.open("varun1.txt", ios::in) ;
while (file.read((char *) this, sizeof(ticket)))
{
if (sno == i)
break ;
i++ ;
}
file.close() ;
strcpy(pfltno,fltno) ;
if (p.seats(sno) >= 250)
{
gotoxy(5,21) ;
cout <<"\nSorry! seats are not available." ;
getch() ;
return ;
}
gotoxy(3,23) ;
cout <<" ";
gotoxy(3,23) ;
cout <<"E=ECONOMIC, X=EXECUTIVE or PRESS <ENTER> TO EXIT" ;
do
{
gotoxy(3,21) ;
cout <<" ";
gotoxy(3,21) ;
cout <<"By which Class you want to travel : " ;
pclass = getche() ;
pclass = toupper(pclass) ;
if (pclass == 13)
return ;
} while (pclass != 'E' && pclass != 'X') ;
clrscr() ;
gotoxy(69,3) ;
cout <<"<0>=EXIT" ;
gotoxy(34,2) ;
cout <<"RESERVATION" ;
gotoxy(5,5) ;
cout <<"NAME : " ;
gotoxy(5,6) ;
cout <<"ADDRESS : " ;
gotoxy(5,7) ;
cout <<"SEX M/F : " ;
gotoxy(5,8) ;
cout <<"AGE : " ;
do
{
valid = 1 ;
gotoxy(5,22) ; clreol() ;
cout <<"ENTER NAME OF THE PASSENGER" ;
gotoxy(15,5) ; clreol() ;
gets(pname) ;
if (pname[0] == '0')
return ;
if (strlen(pname) < 1 || strlen(pname) > 25)
{
valid = 0 ;
gotoxy(5,22) ; clreol() ;
cout <<"\nEnter Correctly (Range: 1..25)" ;
getch() ;
}
} while (!valid) ;
do
{
valid = 1 ;
gotoxy(5,22) ; clreol() ;
cout <<"ENTER ADDRESS OF THE PASSENGER" ;
gotoxy(15,6) ;
clreol() ;
gets(paddress) ;
if (paddress[0] == '0')
return ;
if (strlen(paddress) < 1 || strlen(paddress) > 35)
{
valid = 0 ;
gotoxy(5,22) ; clreol() ;
cout <<"\nEnter Correctly (Range: 1..35)" ;
getch() ;
}
} while (!valid) ;
do
{
gotoxy(5,22) ; clreol() ;
cout <<"ENTER SEX OF THE PASSENGER" ;
gotoxy(15,7) ;
clreol() ;
psex = getche() ;
psex = toupper(psex) ;
if (psex == '0')
return ;
} while (psex != 'M' && psex != 'F') ;
do
{
valid = 1 ;
gotoxy(5,22) ; clreol() ;
cout <<"ENTER AGE OF THE PASSENGER" ;
gotoxy(15,8) ; clreol() ;
gets(t1) ;
t2 = atoi(t1) ;
page = t2 ;
if (t1[0] == '0')
return ;
if (page < 1 || page > 100)
{
valid = 0 ;
gotoxy(5,22) ;
clreol() ;
cout <<"\nENTER CORRECTLY" ;
getch() ;
}
} while (!valid) ;
clrscr() ;
draw d ;
d.box(15,5,65,21,'±') ;
d.line_hor(16,64,7,'±') ;
gotoxy(33,6) ;
cout <<"Ticket no. " <<tno ;
gotoxy(17,9) ;
cout <<from <<" to " <<to ;
gotoxy(45,9) ;
cout <<"Flight no. " <<pfltno ;
gotoxy(20,11) ;
cout <<"Passenger name : " <<pname ;
gotoxy(20,13) ;
cout <<"Address : " <<paddress ;
gotoxy(20,15) ;
cout <<"Sex : " <<psex ;
gotoxy(20,17) ;
cout <<"Age : " <<page ;
gotoxy(45,19) ;
if (pclass == 'E')
cout <<"Total fare: " <<ecofare ;
else
cout <<"Total fare: " <<exefare ;
p.add_record(tno,sno,pname,paddress,page,psex,pclass) ;
getch() ;
}

//function to add the given data in the passenger's file(varun2.txt)


void passenger :: add_record(int tno, int sno, char pname[26], char paddress[36], int
page, char psex, char pclass)
{
fstream file ;
file.open("varun2.txt", ios::app) ;
ticketno = tno ;
slno = sno ;
strcpy(name,pname) ;
strcpy(address,paddress) ;
age = page ;
sex = psex ;
Class = pclass ;
file.write((char *) this, sizeof(passenger)) ;
file.close() ;
}

//function returns the last ticket number in the passenger list


int passenger :: last_ticketno(void)
{
fstream file ;
file.open("varun2.txt", ios::in) ;
int count=0 ;
while (file.read((char *) this, sizeof(passenger)))
count = ticketno ;
file.close() ;
return count ;
}

//function returns the total number of seats in the passenger file


int passenger :: seats(int sno)
{
fstream file ;
file.open("varun2.txt", ios::in) ;
int count=0 ;
while (file.read((char *) this, sizeof(passenger)))
{
if (sno == slno)
count++ ;
}
file.close() ;
return count ;
}

//function checks if entered ticket number exists or not


int passenger :: found(int tno)
{
fstream file ;
file.open("varun2.txt", ios::in) ;
int found=0 ;
while (file.read((char *) this, sizeof(passenger)))
{
if (tno == ticketno)
{
found = 1 ;
break ;
}
}
file.close() ;
return found ;
}

//function returns passenger's name for the given ticket number


char *passenger :: Name(int tno)
{
fstream file ;
file.open("varun2.txt", ios::in) ;
while (file.read((char *) this, sizeof(passenger)))
{
if (tno == ticketno)
break ;
}
file.close() ;
return name ;
}

//function displays the list of passengers


void passenger :: list(void)
{
clrscr() ;
char t1[10] ;
int t2, sno, valid ;
ticket ticket ;
ticket.enquiry() ;
do
{
valid = 1 ;
gotoxy(3,22) ;
gotoxy(3,23) ;
cout <<"PRESS <ENTER> TO EXIT" ;
gotoxy(3,20) ;
cout <<" ";
gotoxy(3,20) ;
cout <<"Enter Sno. of the FLIGHT for which you want to see list of passenger
";
gets(t1) ;
t2 = atoi(t1) ;
sno = t2 ;
if (strlen(t1) == 0)
return ;
if (sno < 1 || sno > 12)
{
valid = 0 ;
gotoxy(3,22) ;
cout <<" ";
gotoxy(3,22) ;
cout <<"\nENTER CORRECTLY" ;
getch() ;
}
} while (!valid) ;
clrscr() ;
window(1,1,80,25);
textattr(48);
clrscr();
window(3,2,78,24);
textattr(15);
clrscr();
int row=7, found=0, flag=0 ;
char ch ;
draw d ;
d.box(1,2,75,22,218) ;
d.line_hor(2,74,4,196) ;
d.line_hor(2,74,6,196) ;
d.line_hor(2,74,22,196) ;
gotoxy(3,3) ;
cout <<"Flight no. " <<ticket.flightno(sno) ;
gotoxy(32,3) ;
cout <<"LIST OF PASSENGER" ;
textcolor(BLACK) ; textbackground(WHITE) ;
gotoxy(2,5) ;
cprintf(" TICKET NO. NAME CLASS ") ;
textcolor(LIGHTCYAN) ; textbackground(BLACK) ;
fstream file ;
file.open("varun2.txt", ios::in) ;
file.seekg(0,ios::beg) ;
while (file.read((char *) this, sizeof(passenger)))
{
if (sno == slno)
{
flag = 0 ;
delay(20) ;
found = 1 ;
gotoxy(5,row) ;
cout <<ticketno ;
gotoxy(17,row) ;
cout <<name ;
gotoxy(49,row) ;
if (Class == 'X')
cout <<"Executive" ;
else
cout <<"Economic" ;
if ( row == 21 )
{
flag = 1 ;
row = 7 ;
gotoxy(5,22) ;
cout <<"Press any key to continue or Press <ESC> to exit" ;
ch = getch() ;
if (ch == 27)
break ;
clrscr() ;
d.box(1,2,75,22,218) ;
d.line_hor(2,74,4,196) ;
d.line_hor(2,74,6,196) ;
d.line_hor(2,74,22,196) ;
gotoxy(32,3) ;
cout <<"LIST OF PASSENGER" ;
textcolor(BLACK) ;
textbackground(WHITE) ;
gotoxy(2,5) ;
cprintf(" TICKET NO. NAME FLIGHT NO. CLASS
") ;
textcolor(LIGHTCYAN) ; textbackground(BLACK) ;
}
else
row++ ;
}
}
if (!found)
{
gotoxy(5,10) ;
cout <<"\n\t\t\tRecords not found" ;
}
if (!flag)
{
gotoxy(5,22) ;
cout <<"Press any key to continue..." ;
getch() ;
}
file.close() ;
}

//function deletes passenger records for the given ticket no.


void passenger :: delete_ticket(int tno)
{
fstream file ;
file.open("varun2.txt", ios::in) ;
fstream temp ;
temp.open("temp.txt", ios::out) ;
file.seekg(0,ios::beg) ;
while (!file.eof())
{
file.read((char *) this, sizeof(passenger)) ;
if (file.eof())
break ;
if (tno != ticketno)
temp.write((char *) this, sizeof(passenger)) ;
}
file.close() ;
remove("varun2.txt");
temp.close() ;
file.open("varun2.txt", ios::out) ;
temp.open("temp.txt", ios::in) ;
temp.seekg(0,ios::beg) ;
while ( !temp.eof() )
{
temp.read((char *) this, sizeof(passenger)) ;
if ( temp.eof() )
break ;
file.write((char *) this, sizeof(passenger)) ;
}
file.close() ;
temp.close() ;
remove("temp.txt");
}

//function deletes all passenger records for the given flight number
int passenger :: delete_flight(int sno)
{
fstream file ;
file.open("varun2.txt", ios::in) ;
fstream temp ;
temp.open("temp.txt", ios::out) ;
file.seekg(0,ios::beg) ;
int found = 0 ;
while (!file.eof())
{
file.read((char *) this, sizeof(passenger)) ;
if (file.eof())
break ;
if (sno != slno)
temp.write((char *) this, sizeof(passenger)) ;
else
found = 1 ;
}
file.close() ;
temp.close() ;
remove("varun2.txt");
file.open("varun3.txt", ios::out) ;
temp.open("temp.txt", ios::in) ;
temp.seekg(0,ios::beg) ;
while ( !temp.eof() )
{
temp.read((char *) this, sizeof(passenger)) ;
if ( temp.eof() )
break ;
file.write((char *) this, sizeof(passenger)) ;
}
file.close() ;
temp.close() ;
remove("temp.txt");
return found ;
}

//function cancels passenger's ticket


void reserve :: cancellation(void)
{
clrscr() ;
char t1[10], ch ;
int t2, tno, valid ;
do {
valid = 1 ;
gotoxy(3,23) ; clreol() ;
cout <<"PRESS <ENTER> TO SEE list or 0 TO EXIT" ;
gotoxy(3,20) ; clreol() ;
cout <<"Enter ticket no. of the passenger to cancel the ticket " ;
gets(t1) ;
t2 = atoi(t1) ;
tno = t2 ;
if (t1[0] == '0')
return ;
if (strlen(t1) == 0)
{
valid = 0 ;
list() ;
clrscr() ;
}
if (!found(tno) && valid)
{
valid = 0 ;
gotoxy(3,22) ;
clreol() ;
cout <<"\nRecord not found" ;
getch() ;
}
} while (!valid) ;
clrscr() ;
fstream file ;
file.open("varun2.txt", ios::in) ;
while (file.read((char *) this, sizeof(passenger)))
if (ticketno == tno)
break ;
file.close() ;
int i=1 ;
file.open("varun1.txt", ios::in) ;
while (file.read((char *) this, sizeof(ticket)))
{
if (slno == i)
break ;
i++ ;
}
file.close() ;
passenger p ;
draw d ;
d.box(15,5,65,21,'±') ;
d.line_hor(16,64,7,'±') ;
gotoxy(33,6) ;
cout <<"Ticket no. " <<tno ;
gotoxy(17,9) ;
cout <<from <<" to " <<to ;
gotoxy(45,9) ;
cout <<"Flight no. " <<fltno ;
gotoxy(20,11) ;
cout <<"Passenger name : " <<p.Name(tno);
gotoxy(20,13) ;
cout <<"Address : " <<address ;
gotoxy(20,15) ;
cout <<"Sex : " <<sex ;
gotoxy(20,17) ;
cout <<"Age : " <<age ;
gotoxy(45,19) ;
if (Class == 'E')
cout <<"Total fare: " <<ecofare ;
else
cout <<"Total fare: " <<exefare ;
do
{
gotoxy(30,22) ; clreol() ;
cout <<"Cancel this Ticket (y/n) : " ;
ch = getche() ;
ch = toupper(ch) ;
} while (ch != 'Y' && ch != 'N') ;
if (ch == 'N')
return ;
delete_ticket(tno) ;
gotoxy(30,23) ;
cout <<"\nTicket Cancelled" ;
getch() ;
}

//function to display the ticket


void reserve :: dislpay_ticket(void)
{
clrscr() ;
char t1[10], ch ;
int t2, tno, valid ;
do {
valid = 1 ;
gotoxy(3,22) ; clreol() ;
cout <<"PRESS <ENTER> TO SEE list or 0 TO EXIT" ;
gotoxy(3,20) ; clreol() ;
cout <<"Enter ticket no. of the passenger " ;
gets(t1) ;
t2 = atoi(t1) ;
tno = t2 ;
if (t1[0] == '0')
return ;
if (strlen(t1) == 0)
{
valid = 0 ;
list() ;
clrscr() ;
}
if (!found(tno) && valid)
{
valid = 0 ;
gotoxy(3,22) ;
clreol() ;
cout <<"\nRecord not found" ;
getch() ;
}
} while (!valid) ;
clrscr() ;
fstream file ;
file.open("varun2.txt", ios::in) ;
while (file.read((char *) this, sizeof(passenger)))
if (ticketno == tno)
break ;
file.close() ;
int i=1 ;
file.open("varun1.txt", ios::in) ;
while (file.read((char *) this, sizeof(ticket)))
{
if (slno == i)
break ;
i++ ;
}
file.close() ;
passenger p ;
draw d ;
gotoxy(0,35);
cout<<"AIR Ticket";
d.box(15,5,65,21,'±') ;
d.line_hor(16,64,7,'±') ;
gotoxy(33,6) ;
cout <<"Ticket no. " <<tno ;
gotoxy(17,9) ;
cout <<from <<" to " <<to ;
gotoxy(45,9) ;
cout <<"Flight no. " <<fltno ;
gotoxy(20,11) ;
cout <<"Passenger name : " <<p.Name(tno);
gotoxy(20,13) ;
cout <<"Address : " <<address ;
gotoxy(20,15) ;
cout <<"Sex : " <<sex ;
gotoxy(20,17) ;
cout <<"Age : " <<age ;
gotoxy(45,19) ;
if (Class == 'E')
cout <<"Total fare: " <<ecofare ;
else
cout <<"Total fare: " <<exefare ;
gotoxy(10,22) ;
cout <<"Press any key to continue..." ;
getch() ;
}

//function to delete all records of a flight


void reserve :: delete_all(void)
{
clrscr() ;
enquiry() ;
char t1[5] ;
int t2, valid, sno ;
do {
valid = 1 ;
gotoxy(3,23) ;
cout <<" ";
gotoxy(3,23) ;
cout <<"PRESS <ENTER> TO EXIT" ;
gotoxy(3,20) ;
cout <<" ";
gotoxy(3,20) ;
cout <<"Enter Sno. of the FLIGHT for which all passenger records to be deleted : " ;
gets(t1) ;
t2 = atoi(t1) ;
sno = t2 ;
if (strlen(t1) == 0)
return ;
if (sno < 1 || sno > 12)
{
valid = 0 ;
gotoxy(3,23) ;
cout <<" ";
gotoxy(3,23) ;
cout <<"\nENTER CORRECTLY" ;
getch() ;
}
} while (!valid) ;
gotoxy(3,23) ;
if (!delete_flight(sno))
cout <<"\n\t\tRecords not found. Press any key to continue..." ;
else
cout <<"\n\t\tRecords deleted. Press any key to continue..." ;
getch() ;
}

void main(void)
{
void menu();
void leave();
draw d1;
int gm,gd=DETECT;
int w;
initgraph(&gd,&gm,"c:\\tc\\bgi");
settextstyle(GOTHIC_FONT,VERT_DIR,3);
setcolor(BLUE);
outtextxy(0,0,"www.pritpal.plane");
d1.box(19,2,64,24,218) ;
settextstyle(TRIPLEX_FONT,HORIZ_DIR,4);
setcolor(CYAN);
outtextxy(200,80," PRITPAL");
outtextxy(220,170," AIRLINE");
outtextxy(250,260,"RESERVATION");
getch();
closegraph();
int i,j;
draw d ;
passenger p ;
ticket tickt ;
reserve r ;
tickt.addition() ;
char ch ;

while (1)
{
menu();
cprintf("AIR TICKET RESERVATION") ;
gotoxy(29,10) ;
cprintf("~~~~~~~~~~~~~~~~~~~~~~") ;
gotoxy(30,11) ;
cprintf("1: RESERVATION") ;
gotoxy(30,12) ;
cprintf("2: CANCELLATION") ;
gotoxy(30,13) ;
cprintf("3: EDIT PASSENGER RECORDS ->") ;
gotoxy(30,14) ;
cprintf("4: ENQUIRY") ;
gotoxy(30,15) ;
cprintf("5: list OF PASSENGERS") ;
gotoxy(30,16) ;
cprintf("6: QUIT") ;
gotoxy(30,18) ;
cprintf("ENTER YOUR CHOICE ") ;
cin>>ch;
textcolor(GREEN) ;
textbackground(BLACK) ;
clrscr() ;
if (ch == 27 || ch == '6')
{ leave();
break ;
}
switch(ch)
{
case '1':
r.reservation() ;
break;
case '2':
r.cancellation() ;
break;
case '3':
while (1)
{
textcolor(LIGHTGREEN) ;
textbackground(BLACK) ;
clrscr() ;
d.box(19,6,62,20,218) ;
textcolor(LIGHTGREEN) ;
textbackground(BLACK) ;
for (i=7; i<=19; i++)
for ( j=20; j<=61; j++) {
gotoxy(j,i) ;
cprintf(" ") ;
}
gotoxy(29,10) ;
cprintf("EDIT PASSENGER RECORDS") ;
gotoxy(29,11) ;
cprintf("~~~~~~~~~~~~~~~~~~~~~~") ;
gotoxy(33,12) ;
cprintf("1: PASSENGER INFORMATION") ;
gotoxy(33,13) ;
cprintf("2: DELETE") ;
gotoxy(33,14) ;
cprintf("0: EXIT") ;
gotoxy(31,16) ;
cprintf("ENTER YOUR CHOICE ") ;
ch = getche() ;
textcolor(GREEN) ;
textbackground(BLACK) ;
clrscr() ;
if (ch == 27 || ch == '0')
break ;
else if (ch == '1')
r.dislpay_ticket() ;
else if (ch == '2')
r.delete_all() ;
}
break;
case '4':
tickt.enquiry() ;
gotoxy(2,23) ;
cout <<"Press any key to continue..." ;
getch() ;
break;
case '5':
p.list() ;
break;
}
}
}

void menu()
{
int i,j;
draw d ;
clrscr();
window(1,1,80,25);
textattr(48);
clrscr();
window(3,2,78,24);
textattr(15);
clrscr() ;
d.box(19,6,62,20,218) ;
textcolor(BLACK) ;
textbackground(GREEN) ;
for ( i=7; i<=19; i++)
for (j=20; j<=61; j++) {
gotoxy(j,i) ;
cprintf(" ") ;
}
gotoxy(29,9) ;
}

void leave()
{
int gm,gd=DETECT;
int w;
initgraph(&gd,&gm,"");
settextstyle(SANS_SERIF_FONT,HORIZ_DIR,5);
setcolor(6);
outtextxy(180,200," Have @ nice day");
gotoxy(20,10);
settextstyle(GOTHIC_FONT,VERT_DIR,3);
setcolor(BLUE);
outtextxy(0,0,"www.varun.plane");
getch();
closegraph();
}

You might also like