Sie sind auf Seite 1von 15

#include

#include
#include
#include
#include
#include
#include
#include
#include

<graphics.h>
<stdlib.h>
<stdio.h>
<conio.h>
<fstream.h>
<dos.h>
<bios.h>
<string.h>
<ctype.h>

class train
{
public:
char destination[25];
char Class[25];
char Train[25];
char name[50];
char street[100];
char city[15];
char state[15];
char departure[15];
char rlstation[20];
char date[20];
char reservation_no[20];
int Return(char abc[]){return strcmp(reservation_no,abc);}
char age[2];
char sex[1];
void getdestination(char a[50])
{
strcpy(destination,a);
}
void getclass(char b[50])
{
strcpy(Class,b);
}
void gettrain(char c[50])
{
strcpy(Train,c);
}
void getname(char d[50])
{
strcpy(name,d);
}
void getsex(char d[1])
{
strcpy(sex,d);
}
void getage(char w[2])
{
strcpy(age,w);
}
void getstreet(char d[100])
{
strcpy(street,d);
}
void getcity(char d[15])
{
strcpy(city,d);
}
void getstate(char d[15])

{
strcpy(state,d);
}
void getdeparture(char d[15])
{
strcpy(departure,d);
}
void getstation(char d[20])
{
strcpy(rlstation,d);
}
void getdate(char dd[20])
{
strcpy(date,dd);
}
void getRno(char d[50])
{
strcpy(reservation_no,d);
}
void showdestination()
{
textcolor(RED);
gotoxy(10,3);
cout<<"DESTINATION ";
gotoxy(25,3);
cout<<"CLASS
";
gotoxy(40,3);
cout<<"TRAIN
";
gotoxy(55,3);
cout<<"DEPARTING FROM";
gotoxy(10,6);
cout<<"ADDRESS";
gotoxy(25,6);
cout<<"Rl. Station";
gotoxy(40,6);
cout<<"DATE";
gotoxy(55,6);
cout<<"AGE";
textcolor(LIGHTRED);
gotoxy(10,4);
cprintf(destination);
gotoxy(25,4);
cprintf(Class);
gotoxy(40,4);
cprintf(Train);
gotoxy(57,4);
cprintf(city);
gotoxy(10,7);
cprintf(street);
gotoxy(10,8);
cprintf(city);
gotoxy(10,9);
cprintf(state);
gotoxy(25,7);
cprintf(rlstation);
gotoxy(40,7);
cprintf(date);
gotoxy(55,7);
cout<<age[0]<<age[1];
}
};
void transfer()
{
fstream fil,fil1;
train pers;
fil1.open("T.dat",ios::binary|ios::in);
fil.open("BBCCDD.tat",ios::binary|ios::out);
while (fil1.read((char*)&pers,sizeof(pers)))
fil.write((char*)&pers,sizeof(pers));
fil.close();
fil1.close();
}
void cancel()
{ clrscr();
closegraph();
int b=0;

char a[6];
cout<<"Enter your reservation no. ";
cin>>a;
fstream fil,fil1;
train pers;
fil.open("BBCCDD.tat",ios::binary|ios::in);
fil1.open("T.dat",ios::binary|ios::out);
while(fil.read((char*)&pers,sizeof(pers)))
if(pers.Return(a)!=0)
{
fil1.write((char*)&pers,sizeof(pers));
b++ ;
}
if(b)
cout<<"Ticket Cancelled";
else
cout<<"Ticket not found";
fil1.close();
fil.close();
transfer();
cout<<"\nPress any key to continue...........";
getch();
clrscr();
}
void movedown(int x1,int &y1,int step)
{
setcolor(BLACK);
outtextxy(x1,y1,"o");
outtextxy(x1+1,y1+1,"o");
setcolor(13);
y1+=step;
outtextxy(x1,y1,"o");
setcolor(5);
outtextxy(x1+1,y1+1,"o");
}
void moveup(int x1,int &y1,int step)
{
setcolor(BLACK);
outtextxy(x1,y1,"o");
outtextxy(x1+1,y1+1,"o");
setcolor(13);
y1-=step;
outtextxy(x1,y1,"o");
setcolor(5);
outtextxy(x1+1,y1+1,"o");
}
void moveright(int &x1,int y1,int step)
{
setcolor(BLACK);
outtextxy(x1,y1,"o");
outtextxy(x1+1,y1+1,"o");
setcolor(13);
x1+=step;
outtextxy(x1,y1,"o");
setcolor(5);
outtextxy(x1+1,y1+1,"o");

}
void moveleft(int &x1,int y1,int step)
{
setcolor(BLACK);
outtextxy(x1,y1,"o");
outtextxy(x1+1,y1+1,"o");
setcolor(13);
x1-=step;
outtextxy(x1,y1,"o");
setcolor(5);
outtextxy(x1+1,y1+1,"o");
}
void Gscreen()
{
int gdriver = DETECT, gmode, errorcode;
initgraph(&gdriver, &gmode, "c:\\tc\\bgi");
errorcode = graphresult();
if (errorcode != grOk)
{
printf("Graphics error: %s\n", grapherrormsg(errorcode));
printf("Press any key to halt:");
getch();
exit(1);
}
}
void cursor(int &a,int &b,int ulim,int dlim,int minus1,int minus2,int jumpx,int
jumpy)
{
settextstyle(3,1,1);
setcolor(13);
outtextxy(a,b,"o");
setcolor(5);
outtextxy(a+1,b+1,"o");
int step1=jumpx;int step2=jumpy;
//while (bioskey(1)==0);
int key=bioskey(1);
while(key!=7181 )
{
while (bioskey(1)==0);
key=bioskey(0);
if (key==19712 && a<ulim)
moveright(a,b,step1);
if (key==19200 && a>ulim-minus1)
moveleft(a,b,step1);
if (key==20480 && b<dlim)
movedown(a,b,step2);
if (key==18432 && b>dlim-minus2)
moveup(a,b,step2);
}
}
void map(char name[],char name1[],char Day[])
{
closegraph();
Gscreen();
setlinestyle(0,0,0);

rectangle(50,200,54,204);
rectangle(0,120,520,360);
setcolor(RED);
settextstyle(TRIPLEX_FONT, HORIZ_DIR, 2);
outtextxy(20,208,name1);
setcolor(LIGHTRED);
outtextxy(21,209,name1);
setlinestyle(0,0,0);
setcolor(LIGHTGRAY);
randomize();
int k,i,l,x=52,y=200;
for (i=0;i<50;i++)
{
delay(20);
k=random(5);
l=random(4);
line(x,y,x+k,y+l);
x+=k;
y+=l;
}
for (i=0;i<80;i++)
{
delay(20);
k=random(5);
l=random(4);
line(x,y,x+k,y-l);
x+=k;
y-=l;
}
for (i=0;i<30;i++)
{
delay(20);
k=random(5);
l=random(4);
line(x,y,x+k,y+l);
x+=k;
y+=l;
}
for (i=0;i<30;i++)
{
delay(20);
k=random(7);
l=random(8);
line(x,y,x+k,y+l);
x+=k;
y+=l;
}
setlinestyle(0,0,3);
rectangle(x,y,x+4,y+4);
setcolor(RED);
settextstyle(TRIPLEX_FONT, HORIZ_DIR, 2);
outtextxy(x-30,y+8,name);
setcolor(LIGHTRED);
outtextxy(x-29,y+7,name);
settextstyle(8,0,3);
setcolor(CYAN);

outtextxy(10,10,"Route Map");
setcolor(LIGHTCYAN);
outtextxy(11,11,"Route Map");
setcolor(LIGHTBLUE);
outtextxy(10,30,Day);
getch();
}
void helpscreen()
{
Gscreen();
settextstyle(7,0,5);
setcolor(LIGHTBLUE);
for(int i=10;i<200;i+=4)
{
setcolor(BLUE);
outtextxy(i,10,"Help Screen");
setcolor(CYAN);
line(0,50,i,50);
setcolor(LIGHTCYAN);
line(0,51,i,51);
setcolor(CYAN);
line(0,49,i,49); setcolor(BLUE);
outtextxy(i+1,11,"Help Screen");
outtextxy(i,10,"Help Screen");setcolor(LIGHTBLUE);
outtextxy(i+1,11,"Help Screen");
delay(5);
setcolor(BLACK);
outtextxy(i,10,"Help Screen");
outtextxy(i+1,11,"Help Screen");
}
setcolor(BLUE);
outtextxy(i,10,"Help Screen");
setcolor(LIGHTBLUE);
outtextxy(i+1,11,"Help Screen");
delay(200);
settextstyle(6,0,3);
setcolor(122);
outtextxy(10,100," Scroll cursor using arrow keys");
outtextxy(10,140," Press ENTER to choose");
outtextxy(10,180," Do not press ENTER key while presentation goes on");
setcolor(121);
outtextxy(11,101," Scroll cursor using arrow keys");
outtextxy(11,141," Press ENTER to choose");
outtextxy(11,181," Do not press ENTER key while presentation goes on");
getch();
closegraph();
clrscr();
Gscreen();
}
void wizard()
{
Gscreen();
settextstyle(4,0,5);
setcolor(LIGHTRED);

//Reservation Wizard

outtextxy(10,10,"Reservation Wizard");
setcolor(RED);
outtextxy(11,11,"Reservation Wizard");
setcolor(7);
outtextxy(350,50,"welcomes you");
setcolor(8);
outtextxy(351,51,"welcomes you");
for (int i=1;i<340;i++)
{
delay(7);
setcolor(1);
line(0,60,i,60);
line(0,62,i,62);
setcolor(9);
line(0,61,i,61);
}
for(i=61;i<105;i++)
{
delay(7);
setcolor(1);
line(338,i,338,i);
line(340,i,338,i);
setcolor(9);
line(339,i,338,i);
}
for (i=341;i<640;i++)
{
delay(7);
setcolor(1);
line(340,103,i,103);
line(340,105,i,105);
setcolor(9);
line(340,104,i,104);
}
settextstyle(1,0,1);
setcolor(7);int j;
char name1[100]={"Please wait while wizard loads datbase ........"};
outtextxy(15,120,name1);
delay(1000);
setcolor(BLACK);
outtextxy(15,120,name1);
setcolor(CYAN);
settextstyle(4,0,3);
outtextxy(10,140,"Choose Destination");
for(i=1;i<10;i++)
{
j=random(16);
delay(100);
setcolor(j);
rectangle(8,139,300,175);
}
setcolor(12);
rectangle(7,138,301,176);
setcolor(4);
rectangle(6,137,302,177);
rectangle(8,139,300,175);
settextstyle(3,0,2);
setcolor(9);

outtextxy(5,200,"CALCUTTA");
outtextxy(135,200,"BIHAR");
outtextxy(255,200,"BOMBAY");
outtextxy(365,200,"BANGALORE");
setcolor(1);
outtextxy(6,201,"CALCUTTA");
outtextxy(136,201,"BIHAR");
outtextxy(256,201,"BOMBAY");
outtextxy(366,201,"BANGALORE");
setcolor(9);
outtextxy(5,265,"POONA ");
outtextxy(135,265,"JAIPUR");
outtextxy(255,265,"JAMMU ");
outtextxy(365,265,"BHOPAL");
setcolor(1);
outtextxy(6,266,"POONA ");
outtextxy(136,266,"JAIPUR");
outtextxy(256,266,"JAMMU");
outtextxy(366,266,"BHOPAL");
int key,q=40,w=230;
train pers;
fstream file;
cursor(q,w,400,260,340,10,120,70);
setcolor(BLACK);
outtextxy(q,w,"o");
outtextxy(q+1,w+1,"o");
if(q==40 && w==230)
pers.getdestination("Calcutta");
if(q==160 && w==230)
pers.getdestination("Bihar");
if(q==280 && w==230)
pers.getdestination("Bombay");
if(q==400 && w==230)
pers.getdestination("Bangalore");
if(q==40 && w==300)
pers.getdestination("Poona");
if(q==160 && w==300)
pers.getdestination("Jaipur");
if(q==280 && w==300)
pers.getdestination("Jammu");
if(q==400 && w==300)
pers.getdestination("Bhopal");
setcolor(CYAN);
settextstyle(4,0,3);
outtextxy(9,300,"Choose Class");
for(i=1;i<10;i++)
{
j=random(16);
delay(100);

setcolor(j);
rectangle(8,299,300,335);
}
setcolor(12);
rectangle(7,298,301,336);
setcolor(4);
rectangle(6,297,302,337);
rectangle(8,299,300,335);
settextstyle(3,0,2);
setcolor(9);
outtextxy(5,350,"A.C Sleeper");
outtextxy(135,350,"A.C C-Car");
outtextxy(5,420,"A1 Class");
outtextxy(135,420,"A2 Class");
setcolor(1);
outtextxy(6,351,"A.C Sleeper");
outtextxy(136,351,"A.C C-Car");
outtextxy(6,421,"A1 Class");
outtextxy(136,421,"A2 Class");
q=40;w=385;
cursor(q,w,160,395,100,10,120,70);
if(q==40&&w==385)
pers.getclass("A.C Sleeper");
if(q==160&&w==385)
pers.getclass("A.C C-Car");
if(q==40&&w==455)
pers.getclass("A1 Class");
if(q==160&&w==455)
pers.getclass("A2 Class");
setcolor(BLACK);
outtextxy(q,w,"o");
outtextxy(q+1,w+1,"o");
settextstyle(3,0,2);
setcolor(CYAN);
settextstyle(4,0,3);
outtextxy(350,300,"Choose Train");
for(i=1;i<10;i++)
{
j=random(16);
delay(100);
setcolor(j);
rectangle(349,299,600,335);
}
setcolor(12);
rectangle(348,298,601,336);
setcolor(4);
rectangle(347,297,602,337);
rectangle(349,299,600,335);
settextstyle(3,0,2);
setcolor(9);
outtextxy(355,350,"SHATABDI");
outtextxy(485,350,"EXPRESS MAIL");
outtextxy(355,420,"RAJDHANI");

outtextxy(485,420,"JANTA EXPRESS");
setcolor(1);
outtextxy(356,351,"SHATABDI");
outtextxy(486,351,"EXPRESS MAIL");
outtextxy(356,421,"RAJDHANI");
outtextxy(486,421,"JANTA EXPRESS");
q=400;w=385;
cursor(q,w,500,400,100,10,120,70);
settextstyle(SMALL_FONT,0,4);
setcolor(YELLOW);
outtextxy(250,440,"Press key to continue.......");
setcolor(BLACK);
outtextxy(q,w,"o");
outtextxy(q+1,w+1,"o");
if(q==400 && w==385)
pers.gettrain("SHATABDI");
if(q==520 && w==385)
pers.gettrain("EXPRESS MAIL");
if(q==400 && w==455)
pers.gettrain("RAJDHANI");
if(q==520 && w==455)
pers.gettrain("JANTA EXPRESS");
closegraph();
clrscr();
char Name[50],Sex[1],street[100],city[15],state[15],
departure[15],choice,Choice;
char Age[2];
gotoxy(6,3);
cout<<"Enter personal details..";
cout<<endl<<"Enter Name: ";
gets(Name);
pers.getname(Name);
cout<<endl<<"Enter Age: ";
cin>>Age;
pers.getage(Age);
cout<<endl<<"Is "<<Name<<" a Male or Female(M/F): ";
cin>>Sex;
pers.getsex(Sex);
cout<<"Enter your address: ";
cout<<endl<<"House no.: ";
gets(street);
pers.getstreet(street);
cout<<endl<<"City: ";
gets(city);
pers.getcity(city);
cout<<endl<<"State: ";
gets(state);
pers.getstate(state);
cout<<"Press key to continue......";
getch();
char CITY[15],reservation_no[10];
clrscr();
gotoxy(4,2);
cout<<"Enter details regarding your reservation..";

gotoxy(0,4);
cout<<endl<<"Will your departure be from "<<city<<" ";
cin>>choice;
if (choice=='N'||'n')
{
cout<<"Enter city of departure ";
gets(departure);
}
else
strcpy(departure,city);
pers.getdeparture(departure);
for (i=0;i<strlen(departure);i++)
CITY[i]=toupper(departure[i]);
char abcd[6]={"DELHI"};
if(strcmp(CITY,abcd)==0)
{
cout<<"As your departure is from Delhi Reservation Wizard can help";
cout<<endl<<"you book a station ticket:: ENTER CHOICE(1/2/3) ";
cout<<endl<<"1 Nizzamuddin ";
cout<<endl<<"2 New Delhi Rl. St. ";
cout<<endl<<"3 Sarojini Nagar Rl. St. ";
cin>>Choice;
if (Choice==1)
pers.getstation("Nizzamuddin");
if (Choice==2)
pers.getstation("New Delhi Rl. St.");
if (Choice==3)
pers.getstation("Sarojini Nagar");
}
else
{
cout<<"As your departure is not from Delhi Reservation Wizard cannot help";
cout<<endl<<"you book a station ticket, we sincerely regret ";
pers.getstation("Not in Delhi");
}
char day[20];
cout<<endl<<"Enter date of reservation(dd/mm/yy) ";
gets(day);
file.open("BBCCDD.tat",ios::binary|ios::in|ios::app|ios::out);
file.write((char*)&pers,sizeof(pers));
pers.getdate(day);
cout<<endl<<endl<<"Thank You. Please wait while processing is done..";
delay(1000);
map(pers.destination,pers.departure,pers.date);
closegraph();
int gdriver = VGA, gmode = VGAHI, errorcode;
struct palettetype pal;
int ht, y, xmax;
initgraph(&gdriver, &gmode, "c:\\tc\\include");
errorcode = graphresult();
if (errorcode != grOk)
{
printf("Graphics error: %s\n", grapherrormsg(errorcode));
printf("Press any key to halt:");
getch();

exit(1);
}
char u;u=0;
for(i=0;i<910;i++)
cout<<u;
getpalette(&pal);
for (i=0; i<pal.size; i++)
setrgbpalette(pal.colors[i+4], i*4, i*4, 4);
ht = getmaxy() / 16;
xmax = getmaxx();
y = 0;
for (i=0; i<pal.size; i++)
{
setfillstyle(SOLID_FILL, i);
bar(0, y, xmax, y+ht);
y += ht;
}
settextstyle(10,0,4);
for(i=0;i<11;i++)
{
delay(200);
setcolor(i);
outtextxy(0,89,"Your Reservation Number");
setcolor(i*3);
outtextxy(1,90,"Your Reservation Number");
setcolor(i*4);
outtextxy(2,91,"Your Reservation Number");
}
delay(500);
reservation_no[0]=state[0];
reservation_no[1]=city[0];
reservation_no[2]=Name[0];
reservation_no[3]=Name[1];
reservation_no[4]='2';
reservation_no[5]='A';
reservation_no[6]='\0';
setcolor(155);
puts(reservation_no);
pers.getRno(reservation_no);
getch();
closegraph();
gotoxy(25,1);
cout<<"BOOKING TICKET";
pers.showdestination();

file.open("BBCCDD.tat",ios::binary|ios::in|ios::app|ios::out);
file.write((char*)&pers,sizeof(pers));
getch();
}
void openingscreen()
{
top:
Gscreen();
settextstyle(1,0,4);

setcolor(BLUE);
outtext(" WELCOME TO RAILWAY RESERVATION");
outtextxy(250,40,"SYSTEM");
setlinestyle(0,0,0);
setcolor(6);
for (int i=21;i<600;i++)
{
delay(2);
setlinestyle(0,0,0);
setcolor(6);
line(20,35,i,35);
line(20,40,i,40);
setlinestyle(1,0,3);
line(20,36,i,36);
line(20,37,i,37);
line(20,38,i,38);
line(20,39,i,39);
}
setlinestyle(0,0,0);
line(240,75,370,75);
line(240,80,370,80);
setlinestyle(1,0,3);
line(240,76,370,76);
line(240,77,370,77);
line(240,78,370,78);
line(240,79,370,79);
delay(550);
setcolor(RED);
settextstyle(4,0,4);
outtextxy(60,100,"Options");
setcolor(8);
setlinestyle(0,0,0);
line(60,140,160,140);
line(60,142,160,142);
setcolor(7);
line(60,141,160,141);
setcolor(RED);
//for arrow
line(165,124,175,124);
line(165,126,175,126);
line(177,125,172,120);
line(177,125,172,130);
line(179,125,174,120);
line(179,125,174,130);
setcolor(LIGHTRED);
line(165,125,175,125);
line(178,125,173,120);
line(178,125,173,130);
delay(450);
settextstyle(1,0,3);
setcolor(1);
outtextxy(30,145,"a: Reservation Wizard");
outtextxy(30,175,"b: Cancel Reservaion");
outtextxy(30,205,"c: Help");
outtextxy(30,238,"d: Exit");
setcolor(8);
outtextxy(31,146,"a: Reservation Wizard");
outtextxy(31,176,"b: Cancel Reservaion");
outtextxy(31,206,"c: Help");
outtextxy(31,239,"d: Exit");
setcolor(57);

outtextxy(29,144,"a:
outtextxy(29,174,"b:
outtextxy(29,204,"c:
outtextxy(29,237,"d:

Reservation Wizard");
Cancel Reservaion");
Help");
Exit");

int q=265;int w=150;


cursor(q,w,0,320,0,150,0,34);//int &a,int &b,int ulim,int dlim,int minus1,int m
inus2,int jumpx,int jumpy
setcolor(BLACK);
outtextxy(q,w,"o");
outtextxy(q+1,w+1,"o");//174,205,220-3,240
cout<<w;
switch(w)
{
case 150:
wizard();
goto top;
case 184:
cancel();
goto top;
case 218:
helpscreen();
goto top;
case 252:
exit(0);
default:
goto top;
}
//if (w==150)
//wizard();
//if (w==184)
//cancel();
//if (w==286)
//helpscreen();
//if (w==320)
//exit(0);
}

void main()
{
clrscr();
clrscr();
Gscreen();
openingscreen();
getch();
closegraph();
clrscr();
fstream file;
train pers;
char abc[6];
cout<<"Enter reservation no.";
cin>>abc;
file.open("BBCCDD.tat",ios::binary|ios::in|ios::out|ios::app);
file.seekg(0);
file.read((char*)&pers,sizeof(pers));

while(!file.eof())
{
if(pers.Return(abc)==0)
pers.showdestination();
file.read((char*)&pers,sizeof(pers));
}
getch();
}

Das könnte Ihnen auch gefallen