📄 main.cpp
字号:
//主函数,定义各功能模块接口
#include"flight.h"
bool add(Hash&);
bool remove(Hash&);
bool search(char**,int,char**,Hash&);
void book(Hash&,char**,char**);
void cancel(Hash&,char**,char**);
void main()
{
char*key1[]={"BEIJING","CHANGSHA","CHANGCHUN","CHENGDU","CHONGQING","DALIAN","FUZHOU",
"GUIYANG","HAERBIN","HANGZHOU","HAIKOU","HEFEI","HUKEHAOTE","HUNMING","JINAN",
"LASA","NANCHANG","NANJING","NANNING","SANYA","SHENYANG","SHIJIAZHUANG","TAIYUAN",
"TIANJIN","WANHAN","WULUNMUQI","XIAMEN","XIAN","YINCHUAN","ZHENGZHOU"};
int size=30;
int choose;
char*key2[]={"Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"};
Hash mlist(key1,size,key2);
i: cout<<"=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*= "<<endl
<<" /*\\ /*\\ /*\\ /*\\ /*\\ /*\\ "<<endl
<<" |***| |***| |***| |***| |***| |***| "<<endl
<<" \\*/ \\*/ ____ \\*/ \\*/ \\*/ \\*/ "<<endl
<<" | | | | | | | | "<<endl
<<" ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^"<<endl
<<" ****************************************** "<<endl
<<'\n'<<" WELCOME TO AERO SYSTEM "<<'\n'<<endl
<<" ****************************************** "<<endl
<<" =*= =*= "<<endl
<<" =*= 0.add flight message =*="<<endl
<<" =*= 1.remove flight message =*="<<endl
<<" =*= 2.search flight message =*="<<endl
<<" =*= 3.book tickets =*="<<endl
<<" =*= 4.cancel booking =*="<<endl
<<" =*= 5.exit =*="<<endl
<<endl
<<" \\ / "<<endl
<<" \\ _ / EDITBY:黄睦翔, 彭晓倩 "<<endl
<<" ----/_\\---- 吴婷婷, 罗婉玲 "<<endl
<<" x--------------( . )--------------x 陈耘 "<<endl
<<" x|x | |_|\\_/|_| | x|x 04软件5班 "<<endl
<<" x x x x "<<endl
<<"~*~~*~~*~~*~~*~~*~~~*~~*~~*~~*~~*~~*~~*~~*~~*~~*~~*~~*~~*~~*~~*~~*~"<<endl
<<"YOUR CHOICE:";
cin>>choose;
switch(choose)
{
case 0:add(mlist);break;
case 1:remove(mlist);break;
case 2:search(key1,size,key2,mlist);break;
case 3:book(mlist,key1,key2);break;
case 4:cancel(mlist,key1,key2);break;
case 5:break;
default:cout<<"Input error,please enter a right choose:"<<endl;goto i;
}
char other;
j: cout<<"Any thing else do you want to do?(Y/N)"<<endl;
cin>>other;
switch(other)
{case 'Y':
case 'y':goto i;
case 'N':
case 'n':break;
default:goto j;
}
cout<<"all finished!"<<endl;
}
bool add(Hash&list){//插入航班信息
system("cls");
char pw[7],rpw[7]="sw0405";//字符数组,记录六位密码
int t=1; //记录密码输入次数
cout<<"please input the password:xxxxxx"<<endl;
do{
gets(pw);
if(strcmp(pw,rpw))cout<<"wrong password.please input again:"<<endl;
t++;
if(t>3)//密码输入错误三次后跳出系统
{
cout<<"you have input a wrong password for three times, the system will be stoped."<<endl;
return false;
}
}
while(strcmp(pw,rpw));
cout<<"please input the message needed:"<<endl;
airline a;
return list.hash_insert(a);
}
bool remove(Hash&list){//删除航班信息
system("cls");
char pw[7],rpw[7]="sw0405";//字符数组,记录六位密码
int t=1; //记录密码输入次数
cout<<"please input the password:xxxxxx"<<endl;
do{
gets(pw);
if(strcmp(pw,rpw))cout<<"wrong password.please input again:"<<endl;
t++;
if(t>3)//密码输入错误三次后跳出系统
{
cout<<"you have input a wrong password for three times, the system will be stoped."<<endl;
return false;
}
}
while(strcmp(pw,rpw));
int key1,key2,key3;
cout<<"Please input the fligt message:"<<endl<<"choose of destination(number):";
cin>>key1;
cout<<"choose of day(number):";
cin>>key2;
cout<<"plane number:";
cin>>key3;
return list.hash_remove(key1,key2,key3);
}
bool search(char**key1,int size,char**key2,Hash&list){//查询航班信息
system("cls");
cout<<"Please choose your destination:"<<endl;
for(int i=0;i<size;i++)
{
cout<<i<<"."<<key1[i];
if((i+1)%6==0)cout<<endl;
else cout<<ends;
}
int choose1,choose2;
cin>>choose1;
cout<<"Please choose day to take off:"<<endl;
for(int j=0;j<7;j++)
cout<<j<<"."<<key2[j]<<endl;
cout<<"If you are not sure the day,please input 8."<<endl;
cin>>choose2;
if(choose2==8)return list.hash_search(choose1);
else return list.hash_search(choose1,choose2);
}
void book(Hash&list,char**key1,char**key2){//订票
system("cls");
int key3,key4,key5;
for(int i=0;i<30;i++)
{
cout<<i<<"."<<key1[i];
if((i+1)%6==0)cout<<endl;
else cout<<ends;
}
cout<<"Please input the fligt message:"<<endl<<"choose of destination(number):";
cin>>key3;
if(!list.hash_search(key3))return;
for(int j=0;j<7;j++)
cout<<j<<"."<<key2[j]<<endl;
cout<<"choose of day(number):";
cin>>key4;
if(!list.hash_search(key3,key4))return;
cout<<"plane number:";
cin>>key5;
airline*line=list.hash_find(key3,key4,key5);
if(line==NULL){cout<<"no such flight."<<endl;return;}
if(line->rest_ticket()<=0)line->book_wait();
else line->Bookticket();
}
void cancel(Hash&list,char**k1,char**k2){//取消订票
system("cls");
int key1,key2,key3;
cout<<"Please input the fligt message:"<<endl<<"choose of destination(number):";
cin>>key1;
if(!list.hash_search(key1))return;
cout<<"choose of day(number):";
cin>>key2;
if(!list.hash_search(key1,key2))return;
cout<<"plane number:";
cin>>key3;
airline*line=list.hash_find(key1,key2,key3);
if(line==NULL){cout<<"no such flight."<<endl;return;}
line->return_ticket();
if(line->rest_ticket()!=0)
line->back_up(k1,k2);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -