hi!!
i,ve written d
program on airline reservation ....
but i m facing problems regarding the value of seats ... that is how do i sore different values of seats available in diff flights
class air
{
protected:
int z;
char clas[10];
char source[5][10];
char dest[5][10];
int seats;
int l;
public:
void getdata() ;
int search(char c[10],char[10] );
void refresh();
};
void air::getdata()
{
cout<<"WELCOME TO SAHARA AIRLINES";
cout<<"LIST OF SOURCES AND DESTINATION ARE>>>>";
for(int s=0;s<2;s++)
{
cin>>source[s];
for(int d=0;d<5;d++)
{
cin>>dest[d];
cin>>seats;
}
cout<<endl;
}
}
int air::search(char c[10],char b[10])
{
for(int p=0;p<5;p++)
{
if((strcmp(source[p],c)==0))
{
for(int h=0;h<5;h++)
{
if((strcmp(dest[h],b)==0))
{
cout<<"flight exists";
cout<<"enter class"<<endl;
cin>>clas;
cout<<"SEATS>>>>";
cout<<seats;
z=seats;
return (1);
}
else
{
l=1;
}
}
}
else
{
l=1;
}
}
if(l==1)
{
cout<<"sorry no flight exists as per request";
}
}
void air::refresh()
{
seats=z;
}
the main function is
void main()
{
clrscr();
air a;
char k;
char c[10];
char b[10];
fare f;
fstream n;
n.open("c:/s/pooja.txt",ios::in|ios::out|ios::ate|ios::binary|ios::trunc);
a.getdata();
n.write((char*)&a,sizeof(a));
fstream z;
z.open("c:/s/poo.txt",ios::in|ios::out|ios::ate|ios::binary|ios::trunc);
n.seekg(0,ios::beg);
n.read((char*)&a,sizeof(a));
while(n)
{
cout<<"PLEASE ENTER UR CHOICE OF SOURCE AND DESTINATION";
cin>>c>>b;
n.read((char*)&a,sizeof(a));
if( a.search(c,b)==1)
{
f.gets();
f.amt();
}
else
{
exit(0);
}
}
n.close();
n.open("c:/s/pooja.txt",ios::in|ios::out|ios::ate|ios::binary|ios::trunc);
a.refresh();
n.write((char*)&a,sizeof(a));
getch();
}
and also in this particular class which is multi level inherited from d class air:
class tickets:public pass
{
protected:
int j;
char ch;
public:
void seatings();
};
void tickets::seatings()
{
if(z>0)
{
for(j=0;j<b;j++)
{
z--;
cout<<"ur this seat is available for booking"<<endl;
}
cout<<"CONFIRMATION FOR TICKRETS"<<endl;
cout<<"press 'y' to book" ;
cin>>ch;
if(ch=='y')
{
cout<<"ur"<<j<<"tickets r booked "<<endl<<"thank u ";
}
else
for(int k=j;k>0;k--)
{
z++;
}
}
}
the value of z is not passed ??
please help...