汽车乘票购票系统
#include
#include
#include
#include
using namespace std;
ifstream infile1;
ifstream infile2;
ifstream infile3;
class qclx
{
string checi;
string start,end;
string type;
string distance;
string statime,endtime;
double price;
int zws;
public:
void input();
void output();
friend void change1();
};
void qclx::input()
{
infile1>>checi;
infile1>>start;
infile1>>end;
infile1>>type;
infile1>>distance;
infile1>>statime;
infile1>>endtime;
infile1>>price;
infile1>>zws;
}
void qclx::output()
{
cout<<checi<<" "<<start<<" "<<end<<" "<<type<<" "<<distance<<" "
<<statime<<" "<<endtime<<" "<<price<<" "<<zws<<endl;
}
class pwxx
{
string checi;
string time;
int ydps,syps;
public:
void input();
void output();
friend void change();
friend void change1();
};
void pwxx::input()
{
infile2>>checi;
infile2>>time;
infile2>>ydps;
infile2>>syps;
}
void pwxx::output()
{
cout<<checi<<" "<<time<<" "<<"已订票数:"<<ydps<<" "<<"剩余票数:"<<syps<<endl;
}
class dpxx
{
string name;
string num;
string checi;
string date;
string zws;
public:
void input();
void output();
};
void dpxx::input()
{
infile3>>name;
infile3>>num;
infile3>>checi;
infile3>>date;
}
void dpxx::output()
{
cout<<name<<" "<<num<<" "<<checi<<" "<<date<<endl;
}
qclx r1[20];pwxx r2[20];dpxx r3[20];int j=10;
void Input()
{
infile1.open("lyt.txt");
infile2.open("lyt2.txt");
infile3.open("lyt3.txt");
for(int i=0;i
r1[i].input();
for(i=0;i
r2[i].input();
for(i=0;i
r3[i].input();
infile1.close();
infile2.close();
infile3.close();
}
void Output()
{
infile1.open("lyt.txt");
infile2.open("lyt2.txt");
infile3.open("lyt3.txt");
for(int i=0;i
r1[i].output();
cout<<endl;
for(i=0;i
r2[i].output();
cout<<endl;
for(i=0;i
r3[i].output();
infile1.close();
infile2.close();
infile3.close();
}
void change()
{
infile1.open("lyt.txt");
infile2.open("lyt2.txt");
infile3.open("lyt3.txt");
char c1;string str1;int m,n;
cout<<"你是想订票还是退票???1:订票,2:退票。";cin>>n;
switch(n)
{
case 1:
{
cout<<"是否想预定车票 Y or N:";
while(cin>>c1)
{
if(c1=='Y'||c1=='N')
break;
else cout<<"输入错误,请重新输入:";
}
while(c1=='Y')
{
system("cls");
for(int i=0;i
r1[i].output();
cout<<endl;
aa: cout<<"请输入所要乘的第几条路线?";cin>>m;
if(r2[m-1].syps<1)
{
cout<<"该趟车次没有剩余车票!!!"<<endl<<"是否想重新输入路线???Y or N:";
cin>>c1;
if(c1=='Y') goto aa ;
}
else
{
r2[m-1].output();
--r2[m-1].syps;
++r2[m-1].ydps;
cout<<"该车次车票最新数据:"<<endl;
r2[m-1].output();
}
cout<<"是否想继续订票???Y or N:";cin>>c1;
}
break;
}
case 2:
{
cout<<"是否想退定车票 Y or N:";cin>>c1;
while(c1=='Y')
{
system("cls");
for(int i=0;i
r1[i].output();
cout<<endl;
cout<<"请输入想要退订的序号1~10: ";cin>>m;
r2[m-1].output();
--r2[m-1].syps;
r2[m-1].output();
c1='N';break;
}
}
}
infile1.close();
infile2.close();
infile3.close();
}
void change1()
{
infile1.open("lyt.txt");
infile2.open("lyt2.txt");
infile3.open("lyt3.txt");
char c1;int m;
cout<<"是否想修改路线信息???Y or N:";
while(cin>>c1)
{
if(c1=='Y'||c1=='N')
break;
else
cout<<"输入错误,请重新输入。";
}
while(c1=='Y')
{
cout<<"1:增加路线,2:删除路线,3:修改路线: ";cin>>m;
switch(m)
{
case 1:{cout<<"请输入想要新增的路线,例如:k343 九江 武汉 普通火车343公里 2012年3月24号 2012年3月24号 324 122";
cin>>r1[j].checi>>r1[j].start>>r1[j].end>>r1[j].type>>r1[j].distance>>r1[j].statime>>\
r1[j].endtime>>r1[j].price>>r1[j].zws;j++;
for(int i=0;i
r1[i].output();
}break;
case 2:{cout<<"请输入要删除的路线:";cin>>m;
for(m=m-1;m
r1[m]=r1[m+1];
for(int i=0;i
r1[i].output();
}break;
case 3:{cout<<"请输入要修改的路线:";cin>>m;
r1[m].output();
cout<<"请重新输入汽车路线的数据:"<<endl;
cin>>r1[--m].checi>>r1[m].start>>r1[m].end>>r1[m].type>>r1[m].distance>>r1[m].statime>>\
r1[m].endtime>>r1[m].price>>r1[m].zws;
cout<<"请重新输入该路线的票务信息:"<<endl;
cout<<"车次 "<<"时间 "<<"已定票数 "<<"剩余票数 "<<endl;
cin>>r2[m].checi>>r2[m].time>>r2[m].ydps>>r2[m].syps;
}break;
}
cout<<"是否想继续修改路线信息 ? ? ? ";cin>>c1;
}
infile1.close();
infile2.close();
infile3.close();
}
void glz()
{
infile1.open("lyt.txt");
infile2.open("lyt2.txt");
infile3.open("lyt3.txt");
int n=1,mm=3;char a[6]={'l','y','t','l','y','t'},b[6];
cout<<"请输入管理者密码(你有三次输入机会):"<<endl;
while(n!=0)
{
n=0;
for(int i=0;i<6;i++)
{
b[i]=_getch();
_putch('*');
}
cout<<endl;
for(i=0;i<6;i++)
{
if(a[i]!=b[i])
n++;
}
if(n!=0)
cout<<"ERROR!!! 请重新输入密码(你还有"<<--mm<<"次机会): "<<endl;
if(mm==0)
cout<<"你输入密码错误的次数超过三次哦!!!等你过段是假想好了密码在过来吧哈···"<<endl;
change1();
system("cls");
for( i=0;i
r1[i].output();
cout<<endl;
for(i=0;i
r2[i].output();
cout<<endl;
for(i=0;i
r3[i].output();
}
infile1.close();
infile2.close();
infile3.close();
}
char stop()
{
char c;
cout<<"是否想退出系统??? Y or N :";cin>>c;
return c;
}
int main()
{
system("title 长途运输信息");
system("color 87");
char c='Y';
int m;
putchar(004);
cout<<" 1,票务信息查看。 ";
putchar(004);
cout<<" 2,订票退票管理。"<<endl;
putchar(004);
cout<<" 3,路线增加删除修改。";
putchar(004);
cout<<" 4,退出车辆信息查询系统。"<<endl;
Input();
while(c=='Y')
{ infile1.open("lyt.txt");
infile2.open("lyt2.txt");
infile3.open("lyt3.txt");
cout<<"请输入你想要进入的服务:";
cin>>m;
switch(m)
{
case 1:Output();break;
case 2:change();break;
case 3:glz();break;
case 4:c=stop();break;
}
infile1.close();
infile2.close();
infile3.close();
}
infile1.close();
infile2.close();
infile3.close();
return 0;
}