?? 訂票業務.cpp
字號:
//承辦訂票業務
#include"FlightInfo.h"
void BookTicket(FlightNode *F,POList *B,PWList *R) //訂票服務的函數
{
int flag=0;
int Fl; //臨時存放航班號
int N; //臨時存放訂票額
char Na[20]; //臨時存放客戶名字
//返回值
int choice;
int temp;
cout<<"請輸入需乘坐的航班號:\n";
top6: cin>>Fl;
if(!(Fl%5==0))
{
cout<<"輸入錯誤!無此航班號,請重新輸入:";
goto top6;
}
cout<<"請輸入訂票額:\n";
cin>>N;
cout<<"請輸入您的名字:\n";
cin>>Na;
for(int i=0;i<=20;i++)
{
if(Fl==B[i].Fli){temp=i;flag=1;}
}
if(flag==0){cout<<"無此航班\n";return;}
if(F[temp].Left>=N)
{
char choice1;
cout<<"尚有余票,"<<ends<<"飛行日:"<<F[temp].Day<<ends<<"飛機號:"<<F[temp].Plane<<endl;
cout<<"你要訂"<<N<<"張票,確定訂票?(N/Y)"<<endl;
cin>>choice1;
switch(choice1)
{
case 'Y':
//F[temp].Left=100-N將余量賦入Flightline中
case 'y':B[temp].append(Na,N,1);F[temp].Left=100-N;cout<<"訂票成功!\n";break;
default:return ;//re=0;
}
}
else
{
char choice2;
cout<<"余票不足,需要排隊候補嗎?(N/Y)"<<endl;
cin>>choice2;
switch(choice2)
{
case 'Y':
case 'y':R[temp].append(Na,N);cout<<"已進候補名單!\n";R[temp].setEnd();cout<<R[temp].leftLength();break;
default:return ;//re=0;
}
}
cout<<"請選擇下一步操作:1,繼續訂票 2,退票 3.返回上一級\n";
top4: cin>>choice;
if(choice==1)
{
BookTicket(F,B,R);
}
else if(choice==2)
{
ReturnTicket(F,B,R);
}
else if(choice==3)
{
return;
}
else
{
cout<<"輸入錯誤!請重新選擇:";
goto top4;
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -