You are on page 1of 26

/****************************************************************************

**************����������������������������������������Ŀ*********************
**************� Program Developer : SHIKHA & MEENU �*********************
**************� INDIAN RAILWAYS �*********************
**************� Ticket Reservation Program �*********************
**************������������������������������������������*********************
****************************************************************************/

//Header Files used in the Program.


#include<iostream.h>
#include<conio.h>
#include<stdio.h>
#include<graphics.h>
#include<string.h>
#include<fstream.h>
#include<ctype.h>
#include<dos.h>
#include<process.h>

/***************************************************************************
Structure to Input Data temporarily
****************************************************************************/
struct input{ char des;
char train;
long int fare;
}info;

/***************************************************************************
Structure to Store Data
****************************************************************************/
struct ticket{
int r;
char name[20];
int age;
char sex[7];
char departure[10];
char destination[10];
char tname[65];
long int fare;
}tic;

/****************************************************************************
Class containing funtions used in Program
****************************************************************************/
class abc{
void input_data();
void destination();
void line_hor(int, int, int, char) ;
void line_ver(int, int, int, char) ;
void box(int,int,int,int,char) ;
void exita();
void save();
void intro();
void destination1();
void destination2();
void destination3();
void destination4();
void view();
void class1a();
void class1b();
void class2();
void class3();
void getdata();
void cancel();
void reserve();
public:
void open();
void option();
void bye();
};
/*class pqr:public abc
{
int dd,mm,yy;
char name[30];
}; */

void bg()
{
int gdriver = VGA, gmode = VGAHI;
initgraph(&gdriver, &gmode,"c:\\tc\\bgi\\");
}
void abc::open()
{
/* bg();
delay(500);
rectangle(0,19,630,400);
settextstyle(1,0,5);
delay(500);
outtextxy(190,40,"WELCOME");
delay(500);
outtextxy(250,120,"to");
delay(500);
outtextxy(140,200,"Indian Railway");
delay(500);
outtextxy(40,280,"Ticket Reserveation system");
delay(500);
rectangle(5,24,625,395);
delay(2000); */
}

char *ch1=" 2005 New Delhi Kalka Shatabdi Exp 17.15 21.15";
char *ch2=" 2057 New Delhi Chandigarh Jan Shatabdi Exp 14.15 18.15";
char *ch3=" 2011 New Delhi Kalka Shatabdi Exp 07.40 12.00";
char *ch4=" 2311 Howrah Kalka Mail 22.50 03.25";
char *ch5=" 2925 Bandra Kalka Mail 11.00 16.05";
char *ch6=" 4095 Nizamuddin Kalka Himalayan Queen Exp 17.15 21.15";

char *mu1=" 2952 New Delhi Mumbai Rajdhani Exp 16.00 08.35";
char *mu2=" 2954 Mumbai August Kranti Rajdhani Exp 16.55 10.15";
char *mu3=" 2138 Firozpur Mumbai CST Punjab Mail 05.30 07.35";
char *mu4=" 2904 Amritsar Mumbai Golden Temple Mail 07.55 06.05";
char *mu5=" 1058 Amritsar Dadar Exp 20.50 04.40";
char *mu6=" 9024 Firozpur Mumbai Janta Exp 13.35 20.40";
char *ko1=" 2302 New Delhi Howrah Rajdhani Exp 17.00 09.55";
char *ko2=" 2304 New Delhi Howrah Poorva Exp 16.15 16.15";
char *ko3=" 2382 New Delhi Howrah Poorva Exp 16.15 15.30";
char *ko4=" 3040 Delhi Howrah Janta Exp 15.30 05.40";

char *cn1=" 2434 Nizamuddin Chennai Rajdhani Exp 15.30 20.05";


char *cn2=" 2616 New Delhi Chennai Rajdhani Exp 18.40 06.15";
char *cn3=" 2622 New Delhi Chennai Tamil Nadu Exp 22.30 07.05";
char *cn4=" 6032 Jammu Tawi Chennai Tamil Nadu Exp 14.55 11.20";

char *place0="Delhi";
char *place1="Chandigarh";
char *place2="Mumbai";
char *place3="Kolkota";
char *place4="Chennai";

char *sex1="Male";
char *sex2="Female";

//**********************************************************
// FUNCTION TO DRAW HORIZONTAL LINE
//**********************************************************

void abc :: line_hor(int column1, int column2, int row, char c)


{
for ( column1; column1<=column2; column1++ )
{
gotoxy(column1,row) ;
cout <<c ;
}
}

//**********************************************************
// FUNCTION TO DRAW VERTICAL LINE
//**********************************************************

void abc :: line_ver(int row1, int row2, int column, char c)


{
for ( row1; row1<=row2; row1++ )
{
gotoxy(column,row1) ;
cout <<c ;
}
}

//**********************************************************
// FUNCTION TO DRAW BOX LINE
//**********************************************************

void abc :: 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 ;
c2=191 ;
c3=192 ;
c4=217 ;
l1 = 196 ;
l2 = 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) ;
}

void abc::exita()
{
for (int i=25; i>=1; i--)
{
delay(20) ;
gotoxy(1,i) ;
clreol() ;

}
exit(0);
}
void abc::save()
{ int driver,mode;
driver=DETECT;
initgraph(&driver,&mode,"c:\\tc\\bgi");
setbkcolor(BLACK);
gotoxy(20,10);
cout<<"WAIT...................";
textcolor(4);
gotoxy(20,17);
cout<<"SAVING IN THE FILE.......";
gotoxy(13,18);
cout<<" -----------IS COMPLETE.";
setcolor(6);
rectangle(0,235,600,200);
delay(500);
for(int i=0;i<=600;i++)
{
setcolor(4);
rectangle(0,235,i,200);

if(i>300)
delay(4);
else
if(i>10)
delay(6);
else
delay(10);
gotoxy(10,18);
cout<<i/6<<"%";
}
delay(50);
closegraph();
textcolor(WHITE) ;
textbackground(NULL) ;

}
void abc::option()

{
char c1=24,c2=25,c3=175,c;
clrscr() ;
textcolor(WHITE+BLINK) ;
textbackground(GREEN) ;
gotoxy(9,3);
cprintf(" INDIAN RAILWAY ");
textcolor(BLACK) ;
textbackground(YELLOW) ;
gotoxy(9,4);
cprintf(" The Departure staion is New Delhi ");
gotoxy(9,23) ;
cprintf("...... to MOVE......<ENTER> to SELECT......<Esc> to EXIT......");
gotoxy(16,23) ; cout<<c1<<c2;
textcolor(WHITE) ;
textbackground(NULL) ;
gotoxy(25,9) ;cprintf("Introduction - Indian Railways");
gotoxy(25,11) ;cprintf("Book the Ticket");
gotoxy(25,13) ;cprintf("View the Ticket status");
gotoxy(25,15) ;cprintf("Cancel the Ticket");
box(2,1,79,25,216);
gotoxy(23,9);printf("%c",c3);
int slct=2;
_setcursortype(0);
while(c!=13) //while enter is not pressed
{
c=getch();
switch(c)
{
case 27:exita();
case 72: //up arrow
gotoxy(23,7+slct);
cout<<" ";
if(slct==2)slct=8;
else slct=slct-2;
gotoxy(23,7+slct);
cout<<char(175);
sound(500);
delay(100);
nosound();
break;
case 80: //down arrow
gotoxy(23,7+slct);
cout<<" ";
if(slct==8) slct=2;
else slct=slct+2;
gotoxy(23,7+slct);
cout<<char(175);
sound(500);
delay(100);
nosound();
break;

case 13: //enter


switch(slct)
{ case 2:intro();
break;
case 4:destination();
break;
case 6:view();
break;
case 8:cancel();

}
}
}

void abc::intro()
{
clrscr() ;
textcolor(WHITE+BLINK) ;
textbackground(GREEN) ;
gotoxy(9,3);
cprintf(" INDIAN RAILWAY ");
textbackground(NULL) ;
textcolor(GREEN);
gotoxy(9,5);
cprintf("Indian Railways are the largest rail network in Asia and world's\n");
gotoxy(9,7);
cprintf("second largest under one management.Criss crossing the country's\n");
gotoxy(9,9);
cprintf("vast geographical spread.Indian Railways are a multi gauge and\n");
gotoxy(9,11);
cprintf("traction system covering over 1 lakh track kilometers,300 yards,\n");
gotoxy(9,13);
cprintf("2300 goodsheds and 700 repair shops. Its rolling stock fleet\n");
gotoxy(9,15);
cprintf("includes 8300 locomotives, 39000 coaching vehicles and 3.5 lakh\n");
gotoxy(9,17);
cprintf("freight wagons. Its work force is 1.65 million and it runs some\n");
gotoxy(9,19);
cprintf("11000 trains everyday,including 7000 passenger trains.");
textcolor(GREEN+BLINK);
gotoxy(9,21);
cprintf("-------------------It's truly India's LIFELINE-------------------");
textcolor(BLACK) ;
textbackground(YELLOW) ;
gotoxy(9,23);
cprintf(" PRESS ANY KEY TO CONTINUE ");
textcolor(WHITE);
textbackground(NULL);
box(2,1,79,25,216);
_setcursortype(_NOCURSOR);
getch();
option();
}

void abc::destination()
{
char c1=24,c2=25,c3=175,c;
clrscr() ;
textcolor(WHITE+BLINK) ;
textbackground(GREEN) ;
gotoxy(9,3);
cprintf(" INDIAN RAILWAY ");
textcolor(BLACK) ;
textbackground(YELLOW) ;
gotoxy(9,4);
cprintf(" The Departure staion is New Delhi ");
gotoxy(9,23) ;
cprintf("...... to MOVE......<ENTER> to SELECT......<Esc> to EXIT......");
gotoxy(16,23) ; cout<<c1<<c2;
textcolor(WHITE) ;
textbackground(NULL) ;
gotoxy(25,9); cprintf("C H A N D I G A R H");
gotoxy(25,11);cprintf("M U M B A I");
gotoxy(25,13);cprintf("K O L K O T A");
gotoxy(25,15);cprintf("C H E N N A I");
box(2,1,79,25,216);
gotoxy(23,9);printf("%c",c3);
info.des=2;
_setcursortype(0);
while(c!=13) //while enter is not pressed
{
c=getch();
switch(c)
{
case 27:option();
case 72: //up arrow
gotoxy(23,7+info.des);
cout<<" ";
if(info.des==2)info.des=8;
else info.des=info.des-2;
gotoxy(23,7+info.des);
cout<<char(175);
sound(500);
delay(100);
nosound();
break;
case 80: //down arrow
gotoxy(23,7+info.des);
cout<<" ";
if(info.des==8) info.des=2;
else info.des=info.des+2;
gotoxy(23,7+info.des);
cout<<char(175);
sound(500);
delay(100);
nosound();
break;

case 13: //enter


switch(info.des)
{ case 2:destination1();
break;
case 4:destination2();
break;
case 6:destination3();
break;
case 8:destination4();

}
}
}

}
void abc::destination1()
{
char c1=24,c2=25,c3=175,c;
clrscr();
textcolor(WHITE+BLINK) ;
textbackground(GREEN) ;
gotoxy(9,3);
cprintf(" INDIAN RAILWAY ");
textcolor(BLACK) ;
textbackground(YELLOW) ;

gotoxy(9,4);
cprintf(" Train Name Departure Arrival ");
gotoxy(9,23) ;
cprintf("...... to MOVE......<ENTER> to SELECT......<Esc> to EXIT......");
gotoxy(16,23) ; cout<<c1<<c2;
gotoxy(12,6);
cout<<"2005 New Delhi Kalka Shatabdi Exp 17.15 21.15";
gotoxy(12,8);
cout<<"2057 New Delhi Chandigarh Jan Shatabdi Exp 14.15 18.15";
gotoxy(12,10);
cout<<"2011 New Delhi Kalka Shatabdi Exp 07.40 12.00";
gotoxy(12,12);
cout<<"2311 Howrah Kalka Mail 22.50 03.25";
gotoxy(12,14);
cout<<"2925 Bandra Kalka Mail 11.00 16.05";
gotoxy(12,16);
cout<<"4095 Nizamuddin Kalka Himalayan Queen Exp 17.15 21.15";

box(2,1,79,25,216);
textbackground(NULL) ;
textcolor(WHITE);
box(2,1,79,25,216);
gotoxy(10,6);printf("%c",c3);
info.train=2;
_setcursortype(0);
while(c!=13) //while enter is not pressed
{
c=getch();
switch(c)
{
case 27:option();
break;
case 72: //up arrow
gotoxy(10,4+info.train);
cout<<" ";
if(info.train==2)info.train=12;
else info.train=info.train-2;
gotoxy(10,4+info.train);
cout<<char(175);
sound(500);
delay(100);
nosound();
break;
case 80: //down arrow
gotoxy(10,4+info.train);
cout<<" ";
if(info.train==12)info.train=2;
else info.train=info.train+2;
gotoxy(10,4+info.train);
cout<<char(175);
sound(500);
delay(100);
nosound();
break;

case 13: //enter


switch(info.train)
{ case 2:class1a();
break;
case 4:class1a();
break;
case 6:class1a();
break;
case 8:class2();
break;
case 10:class2();
break;
case 12:class3();
break;
}
}
}
}
void abc::destination2()
{
char c1=24,c2=25,c3=175,c;
clrscr();
textcolor(WHITE+BLINK) ;
textbackground(GREEN) ;
gotoxy(9,3);
cprintf(" INDIAN RAILWAY ");
textcolor(BLACK) ;
textbackground(YELLOW) ;

gotoxy(9,4);
cprintf(" Train Name Departure Arrival ");
gotoxy(9,23) ;
cprintf("...... to MOVE......<ENTER> to SELECT......<Esc> to EXIT......");
gotoxy(16,23) ; cout<<c1<<c2;
gotoxy(12,6);
cout<<"2952 New Delhi Mumbai Rajdhani Exp 16.00 08.35";
gotoxy(12,8);
cout<<"2954 Mumbai August Kranti Rajdhani Exp 16.55 10.15";
gotoxy(12,10);
cout<<"2138 Firozpur Mumbai CST Punjab Mail 05.30 07.35";
gotoxy(12,12);
cout<<"2904 Amritsar Mumbai Golden Temple Mail 07.55 06.05";
gotoxy(12,14);
cout<<"1058 Amritsar Dadar Exp 20.50 04.40";
gotoxy(12,16);
cout<<"9024 Firozpur Mumbai Janta Exp 13.35 20.40";

box(2,1,79,25,216);
textbackground(NULL) ;
textcolor(WHITE);
box(2,1,79,25,216);
gotoxy(10,6);printf("%c",c3);
info.train=2;
_setcursortype(0);
while(c!=13) //while enter is not pressed
{
c=getch();
switch(c)
{
case 27:option();
break;
case 72: //up arrow
gotoxy(10,4+info.train);
cout<<" ";
if(info.train==2)info.train=12;
else info.train=info.train-2;
gotoxy(10,4+info.train);
cout<<char(175);
sound(500);
delay(100);
nosound();
break;
case 80: //down arrow
gotoxy(10,4+info.train);
cout<<" ";
if(info.train==12)info.train=2;
else info.train=info.train+2;
gotoxy(10,4+info.train);
cout<<char(175);
sound(500);
delay(100);
nosound();
break;

case 13: //enter


switch(info.train)
{ case 2:class1b();
break;
case 4:class1b();
break;
case 6:class2();
break;
case 8:class2();
break;
case 10:class3();
break;
case 12:class3();
break;
}
}
}
}

void abc::destination3()
{
char c1=24,c2=25,c3=175,c;
clrscr();
textcolor(WHITE+BLINK) ;
textbackground(GREEN) ;
gotoxy(9,3);
cprintf(" INDIAN RAILWAY ");
textcolor(BLACK) ;
textbackground(YELLOW) ;

gotoxy(9,4);
cprintf(" Train Name Departure Arrival ");
gotoxy(9,23) ;
cprintf("...... to MOVE......<ENTER> to SELECT......<Esc> to EXIT......");
gotoxy(16,23) ; cout<<c1<<c2;
gotoxy(12,6);
cout<<"2302 New Delhi Howrah Rajdhani Exp 17.00 09.55";
gotoxy(12,8);
cout<<"2304 New Delhi Howrah Poorva Exp 16.15 16.15";
gotoxy(12,10);
cout<<"2382 New Delhi Howrah Poorva Exp 16.15 15.30";
gotoxy(12,12);
cout<<"3040 Delhi Howrah Janta Exp 15.30 05.40";

box(2,1,79,25,216);
textbackground(NULL) ;
textcolor(WHITE);
box(2,1,79,25,216);
gotoxy(10,6);printf("%c",c3);
info.train=2;
_setcursortype(0);
while(c!=13) //while enter is not pressed
{
c=getch();
switch(c)
{
case 27:option();
break;
case 72: //up arrow
gotoxy(10,4+info.train);
cout<<" ";
if(info.train==2)info.train=8;
else info.train=info.train-2;
gotoxy(10,4+info.train);
cout<<char(175);
sound(500);
delay(100);
nosound();
break;
case 80: //down arrow
gotoxy(10,4+info.train);
cout<<" ";
if(info.train==8)info.train=2;
else info.train=info.train+2;
gotoxy(10,4+info.train);
cout<<char(175);
sound(500);
delay(100);
nosound();
break;

case 13: //enter


switch(info.train)
{ case 2:class1b();
break;
case 4:class2();
break;
case 6:class2();
break;
case 8:class3();
break;
}
}
}
}
void abc::destination4()
{
char c1=24,c2=25,c3=175,c;
clrscr();
textcolor(WHITE+BLINK) ;
textbackground(GREEN) ;
gotoxy(9,3);
cprintf(" INDIAN RAILWAY ");
textcolor(BLACK) ;
textbackground(YELLOW) ;

gotoxy(9,4);
cprintf(" Train Name Departure Arrival ");
gotoxy(9,23) ;
cprintf("...... to MOVE......<ENTER> to SELECT......<Esc> to EXIT......");
gotoxy(16,23) ; cout<<c1<<c2;
gotoxy(12,6);
cout<<"2434 Nizamuddin Chennai Rajdhani Exp 15.30 20.05";
gotoxy(12,8);
cout<<"2616 New Delhi Chennai Rajdhani Exp 18.40 06.15";
gotoxy(12,10);
cout<<"2622 New Delhi Chennai Tamil Nadu Exp 22.30 07.05";
gotoxy(12,12);
cout<<"6032 Jammu Tawi Chennai Tamil Nadu Exp 14.55 11.20";

box(2,1,79,25,216);
textbackground(NULL) ;
textcolor(WHITE);
box(2,1,79,25,216);
gotoxy(10,6);printf("%c",c3);
info.train=2;
_setcursortype(0);
while(c!=13) //while enter is not pressed
{
c=getch();
switch(c)
{
case 27:option();
break;
case 72: //up arrow
gotoxy(10,4+info.train);
cout<<" ";
if(info.train==2)info.train=8;
else info.train=info.train-2;
gotoxy(10,4+info.train);
cout<<char(175);
sound(500);
delay(100);
nosound();
break;
case 80: //down arrow
gotoxy(10,4+info.train);
cout<<" ";
if(info.train==8)info.train=2;
else info.train=info.train+2;
gotoxy(10,4+info.train);
cout<<char(175);
sound(500);
delay(100);
nosound();
break;

case 13: //enter


switch(info.train)
{ case 2:class1b();
break;
case 4:class2();
break;
case 6:class2();
break;
case 8:class3();
break;
}
}
}
}
void abc::class1a()
{
char c1=24,c2=25,c3=175,c;
clrscr() ;
textcolor(WHITE+BLINK) ;
textbackground(GREEN) ;
gotoxy(9,3);
cprintf(" INDIAN RAILWAY ");
textcolor(BLACK) ;
textbackground(YELLOW) ;
gotoxy(9,4);
cprintf(" The Departure staion is New Delhi ");
gotoxy(9,23) ;
cprintf("...... to MOVE......<ENTER> to SELECT......<Esc> to EXIT......");
gotoxy(16,23) ; cout<<c1<<c2;
textcolor(WHITE) ;
textbackground(NULL) ;

gotoxy(25,9) ;
cprintf("A C Executive Chair Car");
gotoxy(25,11) ;
cprintf("A C Chair Car");
gotoxy(58,8);
cprintf("Fare Price");
switch(info.des)
{ case 2: gotoxy(62,9) ;
cprintf("Rs 865");
gotoxy(62,11) ;
cprintf("Rs 435");
break;
}
box(2,1,79,25,216);
gotoxy(23,9);printf("%c",c3);
int slct=2;
_setcursortype(0);
while(c!=13) //while enter is not pressed
{
c=getch();
switch(c)
{
case 27:option();
case 72: //up arrow
gotoxy(23,7+slct);
cout<<" ";
if(slct==2)slct=4;
else slct=slct-2;
gotoxy(23,7+slct);
cout<<char(175);
sound(500);
delay(100);
nosound();
break;
case 80: //down arrow
gotoxy(23,7+slct);
cout<<" ";
if(slct==4) slct=2;
else slct=slct+2;
gotoxy(23,7+slct);
cout<<char(175);
sound(500);
delay(100);
nosound();
break;

case 13: //enter


switch(info.des)
{ case 2:switch(slct)

{ case 2:info.fare=865;
break;
case 4:info.fare=435;
break;
}
}
}
}
getdata();
}

void abc::class1b()
{
char c1=24,c2=25,c3=175,c;
clrscr() ;
textcolor(WHITE+BLINK) ;
textbackground(GREEN) ;
gotoxy(9,3);
cprintf(" INDIAN RAILWAY ");
textcolor(BLACK) ;
textbackground(YELLOW) ;
gotoxy(9,4);
cprintf(" The Departure staion is New Delhi ");
gotoxy(9,23) ;
cprintf("...... to MOVE......<ENTER> to SELECT......<Esc> to EXIT......");
gotoxy(16,23) ; cout<<c1<<c2;
textcolor(WHITE) ;
textbackground(NULL) ;
gotoxy(25,9) ;
cprintf("First A C");
gotoxy(25,11) ;
cprintf("Two Tier A C Sleeper");
gotoxy(25,13) ;
cprintf("Three Tier A C");
gotoxy(58,8);
cprintf("Fare Price");
switch(info.des)
{
case 4: gotoxy(61,9);
cprintf("Rs 4180");
gotoxy(61,11) ;
cprintf("Rs 2405");
gotoxy(61,13);
cprintf("Rs 1485");
break;
case 6: gotoxy(61,9);
cprintf("Rs 4585");
gotoxy(61,11) ;
cprintf("Rs 2690");
gotoxy(61,13);
cprintf("Rs 1635");
break;
case 8: gotoxy(61,9);
cprintf("Rs 8195");
gotoxy(61,11) ;
cprintf("Rs 4235");
gotoxy(61,13);
cprintf("Rs 2765");
break;

}
box(2,1,79,25,216);
gotoxy(23,9);printf("%c",c3);
int slct=2;
_setcursortype(0);
while(c!=13) //while enter is not pressed
{
c=getch();
switch(c)
{
case 27:option();
case 72: //up arrow
gotoxy(23,7+slct);
cout<<" ";
if(slct==2)slct=6;
else slct=slct-2;
gotoxy(23,7+slct);
cout<<char(175);
sound(500);
delay(100);
nosound();
break;
case 80: //down arrow
gotoxy(23,7+slct);
cout<<" ";
if(slct==6) slct=2;
else slct=slct+2;
gotoxy(23,7+slct);
cout<<char(175);
sound(500);
delay(100);
nosound();
break;

case 13: //enter


switch(slct)
{ case 2:switch(info.des)
{
case 4:info.fare=4180;
break;
case 6:info.fare=4585;
break;
case 8:info.fare=8195;
break;
}
break;
case 4:switch(info.des)
{
case 4:info.fare=2405;
break;
case 6:info.fare=2690;
break;
case 8:info.fare=4235;
break;
}
break;
case 6:switch(info.des)
{ case 4:info.fare=1485;
break;
case 6:info.fare=1635;
break;
case 8:info.fare=2765;
break;
}

}
}
}
getdata();
}

void abc::class2()
{
char c1=24,c2=25,c3=175,c;
clrscr() ;
textcolor(WHITE+BLINK) ;
textbackground(GREEN) ;
gotoxy(9,3);
cprintf(" INDIAN RAILWAY ");
textcolor(BLACK) ;
textbackground(YELLOW) ;
gotoxy(9,4);
cprintf(" The Departure staion is New Delhi ");
gotoxy(9,23) ;
cprintf("...... to MOVE......<ENTER> to SELECT......<Esc> to EXIT......");
gotoxy(16,23) ; cout<<c1<<c2;
textcolor(WHITE) ;
textbackground(NULL) ;
gotoxy(25,9) ;
cprintf("First A C");
gotoxy(25,11) ;
cprintf("Two Tier A C Sleeper");
gotoxy(25,13) ;
cprintf("Three Tier A C");
gotoxy(58,8);
cprintf("Fare Price");
switch(info.des)
{
case 2: gotoxy(62,9);
cprintf("Rs 917");
gotoxy(62,11) ;
cprintf("Rs 477");
gotoxy(62,13);
cprintf("Rs 295");
break;
case 4: gotoxy(61,9);
cprintf("Rs 3398");
gotoxy(61,11) ;
cprintf("Rs 1748");
gotoxy(61,13);
cprintf("Rs 1093");
break;
case 6: gotoxy(61,9);
cprintf("Rs 3258");
gotoxy(61,11) ;
cprintf("Rs 1676");
gotoxy(61,13);
cprintf("Rs 1048");
break;
case 8: gotoxy(61,9);
cprintf("Rs 4168");
gotoxy(61,11) ;
cprintf("Rs 2144");
gotoxy(61,13);
cprintf("Rs 1340");
break;

}
box(2,1,79,25,216);
gotoxy(23,9);printf("%c",c3);
int slct=2;
_setcursortype(0);
while(c!=13) //while enter is not pressed
{
c=getch();
switch(c)
{
case 27:option();
case 72: //up arrow
gotoxy(23,7+slct);
cout<<" ";
if(slct==2)slct=6;
else slct=slct-2;
gotoxy(23,7+slct);
cout<<char(175);
sound(500);
delay(100);
nosound();
break;
case 80: //down arrow
gotoxy(23,7+slct);
cout<<" ";
if(slct==6) slct=2;
else slct=slct+2;
gotoxy(23,7+slct);
cout<<char(175);
sound(500);
delay(100);
nosound();
break;

case 13: //enter


switch(slct)
{ case 2:switch(info.des)
{
case 2:info.fare=917;
break;
case 4:info.fare=3398;
break;
case 6:info.fare=3258;
break;
case 8:info.fare=4168;
break;
}
break;
case 4:switch(info.des)
{ case 2:info.fare=477;
break;
case 4:info.fare=1748;
break;
case 6:info.fare=1676;
break;
case 8:info.fare=2144;
break;
}
break;
case 6:switch(info.des)
{ case 2:info.fare=295;
break;
case 4:info.fare=1093;
break;
case 6:info.fare=1048;
break;
case 8:info.fare=1340;
break;
}
break;
}

}
}
getdata();
}
void abc::class3()
{
char c1=24,c2=25,c3=175,c;
clrscr() ;
textcolor(WHITE+BLINK) ;
textbackground(GREEN) ;
gotoxy(9,3);
cprintf(" INDIAN RAILWAY ");
textcolor(BLACK) ;
textbackground(YELLOW) ;
gotoxy(9,4);
cprintf(" The Departure staion is New Delhi ");
gotoxy(9,23) ;
cprintf("...... to MOVE......<ENTER> to SELECT......<Esc> to EXIT......");
gotoxy(16,23) ; cout<<c1<<c2;
textcolor(WHITE) ;
textbackground(NULL) ;
gotoxy(25,9) ;
cprintf("First Class");
gotoxy(25,11) ;
cprintf("Sleeper Class");
gotoxy(25,13) ;
cprintf("Second Class Seat");

gotoxy(58,8);
cprintf("Fare Price");
switch(info.des)
{ case 2: gotoxy(62,9);
cprintf("Rs 344");
gotoxy(62,11) ;
cprintf("Rs 105");
gotoxy(63,13);
cprintf("Rs 66");
break;
case 4: gotoxy(61,9);
cprintf("Rs 1275");
gotoxy(62,11) ;
cprintf("Rs 389");
gotoxy(62,13);
cprintf("Rs 243");
break;
case 6: gotoxy(61,9);
cprintf("Rs 1222");
gotoxy(62,11) ;
cprintf("Rs 373");
gotoxy(62,13);
cprintf("Rs 233");
break;
case 8: gotoxy(61,9);
cprintf("Rs 1563");
gotoxy(62,11) ;
cprintf("Rs 477");
gotoxy(62,13);
cprintf("Rs 298");
break;
}
box(2,1,79,25,216);
gotoxy(23,9);printf("%c",c3);
int slct=2;
_setcursortype(0);
while(c!=13) //while enter is not pressed
{
c=getch();
switch(c)
{
case 27:option();
case 72: //up arrow
gotoxy(23,7+slct);
cout<<" ";
if(slct==2)slct=6;
else slct=slct-2;
gotoxy(23,7+slct);
cout<<char(175);
sound(500);
delay(100);
nosound();
break;
case 80: //down arrow
gotoxy(23,7+slct);
cout<<" ";
if(slct==6) slct=2;
else slct=slct+2;
gotoxy(23,7+slct);
cout<<char(175);
sound(500);
delay(100);
nosound();
break;

case 13: //enter


switch(slct)
{
case 2:switch(info.des)
{ case 2:info.fare=344;
break;
case 4:info.fare=1275;
break;
case 6:info.fare=1222;
break;
case 8:info.fare=1563;
break;
}
break;
case 4:switch(info.des)
{ case 2:info.fare=105;
break;
case 4:info.fare=389;
break;
case 6:info.fare=373;
break;
case 8:info.fare=477;
break;
}
break;
case 6:switch(info.des)
{
case 2:info.fare=66;
break;
case 4:info.fare=243;
break;
case 6:info.fare=233;
break;
case 8:info.fare=298;
break;
}
break;
}

}
}
getdata();
}

void abc::getdata()
{int i,no;
char ch;
clrscr();
textcolor(WHITE+BLINK) ;
textbackground(GREEN) ;
gotoxy(9,3);
cprintf(" INDIAN RAILWAY ");
gotoxy(9,4);
textcolor(BLACK) ;
textbackground(YELLOW) ;
gotoxy(9,4);
cprintf(" Please Input the Required Data ");
textcolor(WHITE) ;
textbackground(NULL) ;
gotoxy(9,23);
cprintf(" Note:- Input a numeric I.D. number ");
int ct=0,pos;
fstream file;
file.open("train.dat",ios::binary|ios::out|ios::end|ios::in);
file.seekg(0);
while(file.read((char*)&tic,sizeof(ticket)))
{ct=ct++;
}
file.clear();
gotoxy(25,10);
cout<<"Enter I.D. of the Person :";
cin>>tic.r;
gotoxy(25,11);
cout<<"Enter Name of the Person :";
gets(tic.name);
gotoxy(25,13);cout<<"Enter Age of the Person :";
cin>>tic.age;

x:
gotoxy(25,15);
cout<<"Enter Sex(m/f) ofthe Person:";
ch=getch();
if((ch=='M')||(ch=='F')||(ch=='m')||(ch=='f'))
{if((ch=='M')||(ch=='m'))
strcpy(tic.sex,sex1);
else
strcpy(tic.sex,sex2);
}
else
goto x;

strcpy(tic.departure,place0);

switch(info.des)
{ case 2:strcpy(tic.destination,place1);
break;
case 4:strcpy(tic.destination,place2);
break;
case 6:strcpy(tic.destination,place3);
break;
case 8:strcpy(tic.destination,place4);
break;
}

switch(info.des)
{ case 2:switch(info.train)
{ case 2:strcpy(tic.tname,ch1);
break;
case 4:strcpy(tic.tname,ch2);
break;
case 6:strcpy(tic.tname,ch3);
break;
case 8:strcpy(tic.tname,ch4);
break;
case 10:strcpy(tic.tname,ch5);
break;
case 12:strcpy(tic.tname,ch6);
}
break;
case 4:switch(info.train)
{ case 2:strcpy(tic.tname,mu1);
break;
case 4:strcpy(tic.tname,mu2);
break;
case 6:strcpy(tic.tname,mu3);
break;
case 8:strcpy(tic.tname,mu4);
break;
case 10:strcpy(tic.tname,mu5);
break;
case 12:strcpy(tic.tname,mu6);
}
break;
case 6:switch(info.train)
{ case 2:strcpy(tic.tname,ko1);
break;
case 4:strcpy(tic.tname,ko2);
break;
case 6:strcpy(tic.tname,ko3);
break;
case 8:strcpy(tic.tname,ko4);
break;
}
break;
case 8: switch(info.train)
{ case 2:strcpy(tic.tname,cn1);
break;
case 4:strcpy(tic.tname,cn2);
break;
case 6:strcpy(tic.tname,cn3);
break;
case 8:strcpy(tic.tname,cn4);
break;
}
break;

tic.fare=info.fare;
pos=ct*sizeof(ticket);
file.seekp(pos,ios::beg);
file.write((char*)&tic,sizeof(ticket));
file.close();
delay(2500);
save();
option();
}

void abc::cancel()
{ int r;
clrscr();
textcolor(WHITE+BLINK) ;
textbackground(GREEN) ;
gotoxy(9,3);
cprintf(" INDIAN RAILWAY ");
gotoxy(9,4);
textcolor(BLACK) ;
textbackground(YELLOW) ;
gotoxy(9,4);
cprintf(" Enter the I.D. number you wish to Delete ");
gotoxy(9,25);
cprintf(" Note:- Input a numeric I.D. number ");
textcolor(WHITE) ;
textbackground(NULL) ;
gotoxy(9,10);
cout<<"Enter I.D. of the Person :";
cin>>r;
fstream file;
file.open("train.dat",ios::binary|ios::in);
file.seekg(0);
fstream filex;
filex.open("record.dat",ios::binary|ios::out|ios::in);
filex.seekp(0);
while(file.read((char*)&tic,sizeof(ticket)))
{
if(r!=tic.r)

filex.write((char*)&tic,sizeof(ticket));

}
file.close();
remove("train.dat");
filex.close();
file.open("train.dat",ios::binary|ios::out);
file.seekp(0);

filex.open("record.dat",ios::binary|ios::in);
filex.seekg(0);

while(!filex.eof())
{ filex.read((char*)&tic,sizeof(ticket));
file.write((char*)&tic,sizeof(ticket));
}
file.close();
filex.close();
file.close();
filex.close();
delay(2500);
option();
}

void abc::view()
{
int q;
clrscr();
textcolor(WHITE+BLINK) ;
textbackground(GREEN) ;
gotoxy(9,3);
cprintf(" INDIAN RAILWAY ");
gotoxy(9,4);
textcolor(BLACK) ;
textbackground(YELLOW) ;
gotoxy(9,4);
cprintf(" T I C K E T ");
textcolor(BLACK) ;
textbackground(YELLOW) ;
gotoxy(9,23);
cprintf(" PRESS ANY KEY TO CONTINUE ");
textcolor(WHITE);
textbackground(NULL);
box(2,1,79,25,216);
_setcursortype(_NOCURSOR);
gotoxy(25,5);
cout<<"\n ENTER ID:";
cin>>q;
fstream file;
file.open("train.dat",ios::binary|ios::in|ios::out);
file.seekg(0);
while(file.read((char*)&tic,sizeof(ticket)))
{if(q==tic.r)
{
clrscr();
textcolor(WHITE+BLINK) ;
textbackground(GREEN) ;
gotoxy(9,3);
cprintf(" INDIAN RAILWAY ");
gotoxy(9,4);
textcolor(BLACK) ;
textbackground(YELLOW) ;
gotoxy(9,4);
cprintf(" T.I.C.K.E.T ");
textcolor(BLACK) ;
textbackground(YELLOW) ;
gotoxy(9,23);
cprintf(" PRESS ANY KEY TO CONTINUE ");
textcolor(WHITE);
textbackground(NULL);
box(2,1,79,25,216);
_setcursortype(_NOCURSOR);

textcolor(LIGHTGRAY);
gotoxy(11,8);
cprintf("Ticket No :");
gotoxy(11,9);
cprintf("Name :");
gotoxy(11,10);
cprintf("Age :");
gotoxy(11,11);
cprintf("Sex :");
cout<<tic.sex;
gotoxy(11,12);
cprintf("Departure :");
gotoxy(11,13);
cprintf("Destination:");
gotoxy(11,15);
cprintf("Train Name Departure Arrival ");
gotoxy(11,18);
cprintf("Fare :");

textcolor(WHITE);
gotoxy(23,8);
cout<<tic.r;
gotoxy(23,9);
cout<<tic.name;
gotoxy(23,10);
cout<<tic.age;
gotoxy(23,11);
cout<<tic.sex;
gotoxy(23,12);
cout<<tic.departure;
gotoxy(23,13);
cout<<tic.destination;
gotoxy(9,16);
cout<<tic.tname;
gotoxy(23,18);
cout<<tic.fare;
}
}
file.close();
getch();

option();
}

void main()
{
clrscr();
abc a;
a.open();
a.option();
getch();
}

You might also like