📄 menu.cpp
字号:
#include "menu.h"
#include <conio.h>
#include <stdlib.h>
void Menu::logOn() //登录界面
{
char choice=' ';
cout<<"***************************************"<<endl;
cout<<" 欢迎使用民航订票系统"<<endl;
cout<<" 开发者 ruoshui"<<endl;
cout<<"***************************************"<<endl;
while(choice!='1'&&choice!='2')
{
cout<<endl;
cout<<endl;
cout<<"请选择您的帐户类型:"<<endl;
cout<<"1、管理员账户"<<endl;
cout<<"2、普通用户帐户"<<endl;
cout<<"请输入序号并按回车确认"<<endl;
cin.get(choice);
if(choice=='1')
{
administrator();
break;
}
if(choice=='2')
{
user();
break;
}
break;
}
}
void Menu::user() //用户菜单
{
char adChoice;
char judge='y';
cout<<endl;
cout<<endl;
cout<<"用户您好,请选择您要进行的操作"<<endl;
cout<<"1、查询航班信息(按航班号)"<<endl;
cout<<"2、查询航班信息(按航线)"<<endl;
cout<<"3、订购机票"<<endl;
cout<<"请输入序号并按回车确认执行功能,输入n并确认退出"<<endl;
cin.ignore();
cin.get(adChoice);
while(adChoice=='1'||adChoice=='2'||adChoice=='3'||adChoice=='4'||adChoice=='5')
{
if(adChoice=='1')
{
cout<<endl;
if(list.findByFlightNumber())
{
cout<<"查找已完成"<<endl;
cout<<"按任意键返回菜单"<<endl;
getch();
}
else
{
cout<<"您输入的航班不存在"<<endl;
cout<<"按任意键返回菜单"<<endl;
getch();
}
}
if(adChoice=='2')
{
cout<<endl;
if(list.findByFlight())
{
cout<<"查找已完成"<<endl;
cout<<"按任意键返回菜单"<<endl;
getch();
}
else
{
cout<<"您输入的航班不存在"<<endl;
cout<<"按任意键返回菜单"<<endl;
getch();
}
}
if(adChoice=='3')
{
list.bespeak();
}
cout<<endl;
cout<<endl;
cout<<"请选择您要进行的操作"<<endl;
cout<<"1、查询航班信息(按航班号)"<<endl;
cout<<"2、查询航班信息(按航线)"<<endl;
cout<<"请输入序号并按回车确认执行功能,输入其他字符并确认退出"<<endl;
cin.ignore();
cin.get(adChoice);
}
}
void Menu::administrator() //管理员菜单
{
char adChoice;
char judge='y';
cout<<endl;
cout<<endl;
cout<<"管理员您好,请选择您要进行的操作"<<endl;
cout<<"1、添加一个航班"<<endl;
cout<<"2、删除一个航班"<<endl;
cout<<"3、查询航班信息(按航班号)"<<endl;
cout<<"4、查询航班信息(按航线)"<<endl;
cout<<"5、显示全部信息"<<endl;
cout<<"请输入序号并按回车确认执行功能,输入n并确认退出"<<endl;
cin.ignore();
cin.get(adChoice);
while(adChoice=='1'||adChoice=='2'||adChoice=='3'||adChoice=='4'||adChoice=='5')
{
if(adChoice=='1')
{
while(judge=='y')
{
cout<<endl;
list.add();
cout<<"要继续添加请输入y并回车确认,否则输入n并确认回到菜单"<<endl;
cin.ignore();
cin.get(judge);
}
judge='y';
}
if(adChoice=='2')
{
while(judge=='y')
{
cout<<endl;
list.remove();
cout<<"要继续删除 请输入y并回车确认,否则输入n并确认回到菜单"<<endl;
cin.ignore();
cin.get(judge);
}
judge='y';
}
if(adChoice=='3')
{
cout<<endl;
if(list.findByFlightNumber())
{
cout<<"查找已完成"<<endl;
cout<<"按任意键返回菜单"<<endl;
getch();
}
else
{
cout<<"您输入的航班不存在"<<endl;
cout<<"按任意键返回菜单"<<endl;
getch();
}
}
if(adChoice=='4')
{
cout<<endl;
if(list.findByFlight())
{
cout<<"查找已完成"<<endl;
cout<<"按任意键返回菜单"<<endl;
getch();
}
else
{
cout<<"您输入的航班不存在"<<endl;
cout<<"按任意键返回菜单"<<endl;
getch();
}
}
if(adChoice=='5')
{
cout<<endl;
list.displayAll();
}
cout<<endl;
cout<<endl;
cout<<"请选择您要进行的操作"<<endl;
cout<<"1、添加一个航班"<<endl;
cout<<"2、删除一个航班"<<endl;
cout<<"3、查询航班信息(按航班号)"<<endl;
cout<<"4、查询航班信息(按航线)"<<endl;
cout<<"5、显示全部信息"<<endl;
cout<<"请输入序号并按回车确认执行功能,输入其他字符并确认退出"<<endl;
cin.ignore();
cin.get(adChoice);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -