Professional Documents
Culture Documents
//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>
void addition(void) ;
void enquiry(void) ;
char *flightno(int) ;
};
//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 ;
}
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();
}