C++ 程序设计作业 航空票务管理系统

本文介绍了一个简单的票务系统的图形界面设计与实现过程,包括客户界面和管理员界面的功能选项及密码验证流程。客户可以查询航班信息,而管理员则能够进行更全面的操作。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

仅要求图形界面和范围判断





#include <iostream>
#include <cstring>
#include <cstdio>
using namespace std;
string pass_word;
string real_pass_word = "888888";
void put_user() //输出客户界面 
{
	cout<<endl<<"客户能查看和查询航空信息:"<<endl<<endl;
	cout<<"请输入航班编号:"<<endl;
	cout<<"      1.订购机票"<<endl;
	cout<<"      2.反退机票"<<endl;
	cout<<"      3.查看航班信息"<<endl;
	cout<<"      4.查询航班信息"<<endl;
	cout<<"      0.返回主界面"<<endl;
	int select_mode = 0;
	cin>>select_mode;
	if(select_mode == 0)
	{
		cout<<endl<<"已退出系统"<<endl<<endl;;
			return ;
	}
}


void put_admin() //输出管理员界面 
{
	char pass_word[6];
	cout<<"请输入管理员密码:"<<endl;
	int flag = 3;
	while(flag)
	{
		cin>>pass_word;
		int i;
		for(i = 0; i < real_pass_word.length() ; i++)
		{
			if(pass_word[i] != real_pass_word[i])  //密码判断;
				break; 
		}
		if(i == real_pass_word.length()) //若密码正确则输出操作界面 
		{
			cout<<endl<<"欢迎进入管理界面"<<endl;
			cout<<"输入航班信息"<<endl;
			cout<<"      1. 订购机票"<<endl;
			cout<<"      2. 反退机票"<<endl;
			cout<<"      3. 查看航班信息"<<endl;
			cout<<"      4. 查询航班信息"<<endl;
			cout<<"      5. 修改航班信息"<<endl;
			cout<<"      0. 返回主界面"<<endl;
			cout<<"请输入编号 0- 5:"<<endl;
			int select_mode = 0;
			bool into = false; //判断范围 
			while( !into ) //循环输入操作项直到项合法 
			{
				cin>>select_mode;
				if(select_mode < 0 || select_mode > 5)
				{
					cout<<endl<<"输入错误,请重新输入"<<endl;
					cout<<"请输入编号 0- 5:"<<endl;
				}
				else
				{
					into = true;
				}
			}
			if(select_mode == 0)
			{
				cout<<endl<<"已退出系统"<<endl<<endl;;
				return ;
			}	//此处可通过选择分支结构扩展其他编号操作 
		}
		else
		{
			cout<<endl<<"管理密码错误!请重新输入"<<endl;
			if(flag > 0)
				cout<<"剩余错误次数:"<<flag--<<endl<<endl;
			else
			{
				cout<<"请重新进入系统"<<endl<<endl;
			}
		}
	}
	return ;
}
int put_welcome(int time) //输出欢迎界面 
{
	int mode;
	if(time == 0) // 仅首次输出欢迎表 以后只输出操作提示 效率高 
	{
		cout<<"	#-----------------------------#"<<endl;
		cout<<"	+                             +"<<endl;
		cout<<"	+                             +"<<endl;
		cout<<"	+       欢迎进入票务系统      +"<<endl;
		cout<<"	+           BY 张峻溥         +"<<endl;
		cout<<"	+                             +"<<endl;
		cout<<"	#-----------------------------#"<<endl;
		cout<<endl<<endl<<endl;
	}

	cout<<"管理员进入请按1, 客户用户进入请按2, 结束请按0:"<<endl;

	cin>>mode;

	if(mode == 1)
		put_admin();
	else if(mode == 2)
		put_user();

	else if(mode == 0)
		return -1;
}
int main()
{
	int time = 0;
	while( true )
	{
		int i = put_welcome(time);
		if(i == -1)
			break;
		time ++;
	}
	return 0;
}

#include #include #include #include #define OK 1 #define ERROR 0 typedef struct airline{ char air_num[8]; char plane_num[8]; char end_place[20]; int total; int left; struct airline *next; }airline; typedef struct customer{ char name[8]; char air_num[8]; int seat_num; struct customer *next; }customer; airline *start_air() { airline *a; a=(airline*)malloc(sizeof(airline)); if(a==NULL) a->next=NULL; return a; } customer *start_cus() { customer *c; c=(customer*)malloc(sizeof(customer)); if(c==NULL) c->next=NULL; return c; } airline *modefy_airline(airline *l,char *air_num) { airline *p; p=l->next; for(;p!=NULL;p=p->next) { if(strcmp(air_num,p->air_num)==0) { p->left++; return l; } printf("NO the airline!"); return 0; } } int insert_air(airline **p,char *air_num,char *plane_num,char *end_place,int total,int left) { airline *q; q=(airline*)malloc(sizeof(airline)); strcpy(q->air_num,air_num); strcpy(q->plane_num,plane_num); strcpy(q->end_place,end_place); q->total=total; q->left=left; q->next=NULL; (*p)->next=q; (*p)=(*p)->next; return OK; } int insert_cus(customer **p,char *name,char *air_num,int seat_num) { customer *q; q=(customer*)malloc(sizeof(customer)); strcpy(q->name,name); strcpy(q->air_num,air_num); q->seat_num=seat_num; q->next=NULL; (*p)->next=q; (*p)=(*p)->next; return OK; } int book(airline *a,char *air_num,customer *c,char *name) { airline *p=a; customer *q=c->next; p=a->next; for(;q->next!=NULL;q=q->next){} for(;p->next!=NULL;p=p->next) { if(p->left>0) { printf("Your seat number is %d",(p->total-p->left+1)); insert_cus(&q,name,air_num,p->total-p->left+1); p->left--; return OK; } else { printf("seat is full"); return 0; } } return OK; } int del_cus(customer *c,airline *l,char *name) { customer *p,*pr; char air_num[8]; pr=c; p=pr->next; while(p!=NULL) { if(strcmp(p->name,name)==0) { strcpy(air_num,p->air_num); l=modefy_airline(l,air_num); pr->next=p->next; p=pr->next; printf("finish!"); return OK; } pr=pr->next; p=pr->next; } printf("NO the customer!"); return ERROR; } int search_air(airline *head) { airline *p=head->next; printf("air_num plane_num end_place total left\n"); for(;p!=NULL;p=p->next) { printf("%s %-10s %-8s %-8d%-8d\n",p->air_num,p->plane_num,p->end_place,p->total,p->left); } return OK; } int search_cus(customer *head) { struct customer *q=head->next; printf("name air_num seat_num\n"); for(;q!=NULL;q=q->next) { printf("%-8s%-12s%-d\n",q->name,q->air_num,q->seat_num); } return OK; } int creat_air(airline **l) { airline *p=*l; int i=0; char *air_num[3]={"007af","008af","009af"}; char *plane_num[3]={"plane1","plane2","plane3"}; char *end_place[3]={"Beijing","Shanghai","Tianjin"}; int total[3]={100,100,100}; int left[3]={52,54,76}; for(i=0;i<3;i++) insert_air(&p,air_num,plane_num,end_place,total,left); return OK; } int creat_cus(customer **l) { customer *p=*l; int i=0; char *name[3]={"zhsan","lisi","wangwu"}; char *air_num[3]={"007af","008af","009af"}; int seat_num[3]={2,5,7}; for(i=0;i<3;i++) insert_cus(&p,name,air_num,seat_num); return OK; } void main() { int t=1; customer *cus=start_cus(); airline *air=start_air(); char name[8],air_num[8],ch; creat_air(&air); creat_cus(&cus); while(t==1) { printf("\n"); printf("*********************************\n"); printf("* Welcome to air firm! *\n"); printf("* book--------1 *\n"); printf("* cancel------2 *\n"); printf("* search------3 *\n"); printf("* exit--------4 *\n"); printf("*********************************\n"); ch=getch(); if(ch=='1') { printf("Please input a airline number:"); scanf("%s",air_num); printf("Please input a name:"); scanf("%s",name); book(air,air_num,cus,name); } else if(ch=='2') { printf("Please input the cancel name:"); scanf("%s",name); del_cus(cus,air,name); } else if(ch=='3') { search_air(air); printf("\n"); search_cus(cus); } else if(ch=='4') { t=0;
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值