1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131
|
void ticket::enter() //Enter function
{
cout<<"Personal Information\n\n";
cout<<"Enter passenger's name: ";
gets(name);
cout<<"\nEnter passport number: ";
gets(p_num);
cout<<"\nEnter passenger's age: ";
cin>>age;
cout<<"\nEnter passenger's gender(M/F): ";
cin>>sex;
clrscr();
cout<<"Flight Information"<<endl<<endl;
cout<<"Enter destination: ";
gets(des);
cout<<"\nSelect type of travel class: "<<endl;
cout<<"1)First Class"<<endl;
cout<<"2)Business Class"<<endl;
cout<<"3)Economy Class"<<endl;
cout<<endl;
cout<<"Choice: ";
cin>>t_class;
price=expence(t_class,age);
int len=strlen(des);
for(int j=0;j<20-len;j++)
strcat(des," ");
fstream f1;
flights f;
f1.open("Flight_Record.dat",ios::in|ios::binary);
while(f1.read((char*)&f,sizeof(f)))
if(!strcmp(des,f.retloc()))
strcpy(code,f.retcode());
f1.close();
fstream f2;
for(int i=0;i<7;i++)
{
if(i==0)
{
f2.open("Flight_RecordSunday.dat",ios::in|ios::binary);
while(f2.read((char*)&f,sizeof(f)))
if(!strcmp(code,f.retcode()))
{
strcpy(day,"SUNDAY");
f2.close();
return;
}
}
if(i==1)
{
f2.open("Flight_RecordMonday.dat",ios::in|ios::binary);
while(f2.read((char*)&f,sizeof(f)))
if(!strcmp(code,f.retcode()))
{
strcpy(day,"MONDAY");
f2.close();
return;
}
}
if(i==2)
{
f2.open("Flight_RecordTuesday.dat",ios::in|ios::binary);
while(f2.read((char*)&f,sizeof(f)))
if(!strcmp(code,f.retcode()))
{ strcpy(day,"TUESDAY");
f2.close();
return;
}
}
if(i==3)
{
f2.open("Flight_RecordWednesday.dat",ios::in|ios::binary);
while(f2.read((char*)&f,sizeof(f)))
if(!strcmp(code,f.retcode()))
{ strcpy(day,"WEDNESDAY");
f2.close();
return;
}
}
if(i==4)
{
f2.open("Flight_RecordThursday.dat",ios::in|ios::binary);
while(f2.read((char*)&f,sizeof(f)))
if(!strcmp(code,f.retcode()))
{ strcpy(day,"THURSDAY");
f2.close();
return;
}
}
if(i==5)
{
f2.open("Flight_RecordFriday.dat",ios::in|ios::binary);
while(f2.read((char*)&f,sizeof(f)))
if(!strcmp(code,f.retcode()))
{ strcpy(day,"FRIDAY");
f2.close();
return;
}
}
if(i==6)
{
f2.open("Flight_RecordSaturday.dat",ios::in|ios::binary);
while(f2.read((char*)&f,sizeof(f)))
if(!strcmp(code,f.retcode()))
{ strcpy(day,"SATURDAY");
f2.close();
return;
}
}
f2.close();
}
}
|