📄 airbookingsystem.txt
字号:
for(i=Flight_Count;i<(Flight_Count+m);i++)
{
cout<<endl;
cout<<"\t\t----------------------------------"<<endl;
cout<<"\t\t\t 请输入终点站名:";
cin>>f.Des_Name;
cout<<"\n\t\t\t 请输入航班号(唯一):";
cin>>f.Flight_No;
cout<<"\n\t\t\t 请输入飞机号:";
cin>>f.Plane_No;
while(1)
{
cout<<"\n\t\t\t 请输入飞行周日(1-7):";
cin>>f.Week_Day;
if(f.Week_Day<'1'||f.Week_Day>'7')
{
cout<<"\n\t\t 数据输入错误,按任意键继续输入."<<endl;
getch();
}
else
break;
}
cout<<"\n\t\t\t 请输入乘员定额:";
cin>>f.Customer_Amount;
cout<<"\n\t\t\t 请输入头等舱票价:";
cin>>f.Price[0];
cout<<"\n\t\t\t 请输入普通舱票价:";
cin>>f.Price[1];
cout<<"\n\t\t\t 请输入经济舱票价:";
cin>>f.Price[2];
f.Free_Amount=f.Customer_Amount; //剩余票数与乘员定额相同
}
Flight_Count+=m;
save();
if(Continue()=='n')
return ;
}
//------------航线是否为空函数-------------
int Empty_Flight()
{ read();
if(m==0)
{cout<<endl;
system("cls");
cout<<"\n\n\n\n\n\n\n\n\t\t 对不起,没有相关航线。按任意键返回..."<<endl;
getch();
return 1;
}
else
return 0;
}
//------------航线查看函数-----------------
void Line_See()
{
if(Empty_Flight()) //航班线为空
return;
prefix("航班查看");
cout<<" ┌────┬───┬───┬────┬────┬────┬────────┐"<<endl;
cout<<" │ │ │ │ │ │ │ 票 价 │"<<endl;
cout<<" │终点站名│航班号│飞机号│飞行周日│乘员定额│剩余票数├──┬──┬──┤"<<endl;
cout<<" │ │ │ │ │ │ │头舱│普舱│经舱│"<<endl;
cout<<" ├────┼───┼───┼────┼────┼────┼──┼──┼──┤"<<endl;
for(i=0;i<m;i++)
{cout<<" │"<<setiosflags(ios::left)<<setw(8)<<f.Des_Name<<"│"<<setw(6)<<f.Flight_No<<\
"│"<<setw(6)<<f.Plane_No<< "│"<<setw(7)<<"星期"<<f.Week_Day<< "│ "<<setw(5)<<f.Customer_Amount<<\
"│ "<<setw(5)<<f.Free_Amount<<"│"<<setw(4)<<f.Price[0]<<"│"<<setw(4)<<f.Price[1]<<"│"<<setw(4)<<f.Price[2]<<"│"<<endl;
cout<<" ├────┼───┼───┼────┼────┼────┼──┼──┼──┤"<<endl;
}
cout<<" └────┴───┴───┴────┴────┴────┴──┴──┴──┘"<<endl;
cout<<"\n\t\t\t 按任意键返回子菜单..."<<endl;
getch();
}
//-------航线修改------
void Line_Edit()
{
char answer[20];
if(Empty_Flight()) //航班线为空
return;
while(0==Empty_Flight())
{
prefix("修改航班");
Line_See();
cout<<"警告!如果该修改航班有乘客 将直接退出本操作"<<endl;
cout<<"若该修改航班有乘客,请先退出所有的票再执行本操作"<<endl;
cout<<"\n\t\t\t请输入你要修改的航班号";
cin>>answer;
read2();
for(j=0;j<n;j++)
while(strcmp(c[j].Flight_No,answer)==0)
{
cout<<"该航班有乘客,请先退出所有的票"<<endl;
return;
}
read();
for(i=0;i<m;i++)
if(strcmp(f.Flight_No,answer)==0)
{cout<<"\n\t\t\t请输入新航班号";
cin>>f.Flight_No;
cout<<"\n\t\t\t请输入飞机号";
cin>>f.Plane_No;
cout<<"\n\t\t\t请输终点站名";
cin>>f.Des_Name;
cout<<"\n\t\t\t请输飞行周日";
cin>>f.Week_Day;
cout<<"\n\t\t\t请输乘员定额";
cin>>f.Customer_Amount;
cout<<"\n\t\t\t 请输入头等舱票价:";
cin>>f.Price[0];
cout<<"\n\t\t\t 请输入普通舱票价:";
cin>>f.Price[1];
cout<<"\n\t\t\t 请输入经济舱票价:";
cin>>f.Price[2];
f.Free_Amount=f.Customer_Amount; //剩余票数与乘员定额相同
cout<<"操作完成"<<endl;
getchar();
return;
}
else
{cout<<" 找不到该航班"<<endl;
getchar();
return;}
save();
}
}
void Sub1Menu()
{
char *MenuItem[]={"│ 航空客运航线管理子菜单 │","│ │[1]. 航 线 增 设 │ │",\
"│ │[2]. 航 线 查 看 │ │","│ │[3]. 航 线 修 改 │ │","│ │[4]. 返 回 主 菜 单 │ │"};
while(1)
switch(ModelMenu(MenuItem,5))
{
case '1':{Line_Add();break;}
case '2':{Line_See();break;}
case '3':{Line_Edit();break;}
case '4':{return;}
default:{ErrorMess();}
}
}
//---------------订票办理函数---------------
void Sub2Menu()
{
int flag;
if(Empty_Flight()) //航班线为空
return;
while(0==Empty_Flight())
{
prefix("订票办理");
flag=0; //标志位清零以重新作出判断
cout<<"\n\t\t\t 请输入航班号:";
read2();
Customer_Count=n;
cin>>c[Customer_Count].Flight_No;
read();
for(i=0;i<m;i++)
if(strcmp(f.Flight_No,c[Customer_Count].Flight_No)==0) //调用航线查找函数,若存在则进行以下操作
{ strcpy(c[Customer_Count].Des_Name,f.Des_Name);
strcpy( c[Customer_Count].Plane_No,f.Plane_No);
cout<< "\n\t \t\t该航班还有"<<f.Free_Amount<<"座位"<<endl;
cout<<"\n\t\t\t 请输入订票数:";
cin>>c[Customer_Count].Amount;
if(c[Customer_Count].Amount<=0)
{
cout<<"\n\t\t\t请输入大于零的数,按任意键继续输入."<<endl;
getch();
}//if
else
break;
}//if
else
{cout<<"\n\t\t\t无此航班"<<endl;
getch();}
for(i=0;i<m;i++)
if(strcmp(f.Flight_No,c[Customer_Count].Flight_No)==0)
if(f.Free_Amount>=c[Customer_Count].Amount)
{
c[Customer_Count].Fist_Seat=(f.Customer_Amount-f.Free_Amount+1);
f.Free_Amount-=c[Customer_Count].Amount; //减去定票数
save();
c[Customer_Count].Last_Seat=(c[Customer_Count].Fist_Seat+c[Customer_Count].Amount-1);
cout<<"\n\t\t\t 请输入你的姓名:";
cin>>c[Customer_Count].Name;
if(c[Customer_Count].Name)
{cout<<"\n\t\t\t 请输入你的证件号:";
cin>>c[Customer_Count].bianhao;
}
else
break;
while(c[Customer_Count].bianhao) //数据合法性检验
{
IsEmpty=0;
cout<<"\n\t\t\t 请输入舱位等级(1-3):";
cin>>c[Customer_Count].Rank;
if(!(c[Customer_Count].Rank>='1'&&c[Customer_Count].Rank<='3'))
{
cout<<"\n\t\t输入出错,请输入1-3之间的数,按任意键继续输入."<<endl;
getch();
}
else
break;
}
cout<<"\n\t\t\t 您的座位号为:"<<endl;
cout<<"\n\t\t\t\t从"<<c[Customer_Count].Fist_Seat<<"到"<<c[Customer_Count].Last_Seat<<endl;
Customer_Count=(Customer_Count+1);
n=n+1;
save2();
}//满足定票数
else if(f.Free_Amount==0)
{
cout<<"\n\t\t 对不起,该航线的票已经全部售完!"<<endl;
}
else
{
cout<<"\n\t\t 对不起,该航线的剩余票额数少于你的订票数。"<<endl;
}
if(Continue()=='n')
return;
}//while
}
//-----------------订票乘客信息-----------------
void Display_Reserve(){
int flag=0;
read();
if(Empty_Flight())
return;
prefix("定票乘客名单");
read2();
if(!(c[0].Amount))
{
cout<<"\n\n\n\n\t\t\t对不起,系统中无定票的乘客。"<<endl;
getch();
return;
}
else
{
cout<<" ┌────┬───┬───┬─────────┬────┬───┬───── "<<endl;
cout<<" │姓名 │航班号│飞机号│ 证件号 │ 终点站 │ 舱等 │座位号 │ "<<endl;
cout<<" ├────┼───┼───┼─────────┼────┼───┼────┤ "<<endl;
for(j=0;j<n;j++)
{
cout<<" │"<<setiosflags(ios::left)<<setw(8)<<c[j].Name<<"│"<<setw(6)\
<<c[j].Flight_No<<"│"<<setw(6)<<c[j].Plane_No<<"│"<<setw(18)<<c[j].bianhao<<"│"<<setw(8)<<c[j].Des_Name<<"│"<<setw(6)<<c[j].Rank\
<<"│";
//if(c.Amount>1)
// cout<<setw(5)<<"c.bianhao"<<"│"<<endl;
// else
cout<<"从"<<c[j].Fist_Seat<<"到"<<c[j].Last_Seat<<" │"<<endl;
cout<<" ├────┼───┼───┼─────────┼────┼───┼────┤"<<endl;
}
cout<<" └────┴───┴───┴─────────┴────┴───┴────┘"<<endl;
cout<<"\n\t\t\t 按任意键返回子菜单..."<<endl;
getch();
}
}
void Sub3Menu() //退票操作
{
int k;
int flag=0; //记录满足条件的航线的定票结点
char answer[7],name[7]; //用户输入的航班数据
if(Empty_Flight()) //航班线为空
return;
while(0==Empty_Flight())
{
prefix("退票办理");
read2();
if(!c)
{
cout<<"\n\n\t\t 对不起,系统中暂时无定票乘客..."<<endl;
getch();
return;
}
while(c)
{
flag=0;
prefix("退票办理");
cout<<"\n\t\t\t 请输入航班号:";
cin>>answer;
read();
for(i=0;i<m;i++)
if(strcmp(f.Flight_No,answer)==0)
{
cout<<"\n\t\t\t 请输入您的姓名:";
cin>>name;
if(f.Customer_Amount==f.Free_Amount)
{
cout<<"\n\t\t 很抱歉,该航线暂时无人定票,无法进行退票操作."<<endl;
if(Continue()=='n')//是否继续操作
return;
else
continue; //提前结束本次循环,重新进行退票处理
}
else
for(j=0;j<n;j++)
while(strcmp(c[j].Name,name)==0 ) //查找有无此乘客名
{ flag=1;
k=j;
for(;k<n-1;k++)
{c[k]=c[k+1];
}
f.Free_Amount=f.Free_Amount+c[j].Amount;
save();
n=n-1;
save2();
cout<<"\n\t\t 退票办理已经操作完毕,按任意键返回菜单..."<<endl;
getch();
return;
}
if(!flag)
cout<<"\n\t\t 很抱歉,该航线无此乘客,请查证后再操作..."<<endl;
}
if(Continue()=='n')
return;
}//while
}
}
void Sub4Menu()
{
char *MenuItem[]={"│ 航空客运乘客管理子菜单 │","│ │ [1]. 订票乘客信息 │ │","│ │ [2]. 返回系统菜单 │ │",\
"│ │ 欢迎你的光临 │ │"};
while(1)
switch(ModelMenu(MenuItem,4))
{
case '1':{Display_Reserve();break;}
case '2':{return;}
default:{ErrorMess();}
}
}
void main()
{
Cover();
while(1)
{ save();
save2();
switch(MainMenu())
{
case '1':{Sub1Menu();break;} //航线管理
case '2':{Sub2Menu();break;} //订票办理
case '3':{Sub3Menu();break;} //退票办理
case '4':{Sub4Menu();break;} //乘客管理
case '5':{if(ExitSystem()) return;break;} //退出系统
default:ErrorMess();
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -