航空公司管理系统(迷你版12306)

要求

今天分享一个之前辅导留学生的作业,作业要求如下:

Project E: Airways Management System
Overall description:
Your team is employed by an Airways company for the implementation of a computer
system responsible for a large part of the operation of the company.
Customer specifications:
The system must be able to store the information of planes, flights and passengers of
the company during the years of its operation. There are two types of planes P62 &
P124 with rectangular arrangements of 6*2 & 12*4 seats, respectively. The sources
and destinations of the currently available flights of the company (for simplicity,
assume only direct flights) are allocated from a set of city airports which can be
potentially extended. The different passengers can be allocated to specific flights and
seats.
The system should be able to provide functionality to the different users listed below:
1. An administrator who can include new flights, prices, dates, airports and perhaps
new planes for each of the two available types.
2. A ticket agent who can flexibly search for a specific flight inquired by a customer.
When the customer reserves or books a ticket, then the required details must be stored.
Such information includes flight id, payment details, expiration date of reservation,
route, allocated seat, viewing facilities of the seating plan, etc. Facilities to amend this
information must be provided.
3. A manager who can retrieve statistics about the company’s operation, such as the
number of planes for each type, total passengers per flight, total revenue, etc.

功能主要有3个模块:
1.管理员模块,管理员可以管理新航班、价格、日期、机场等。

2.票务代理模块,可以灵活搜索客户查询的航班信息。
这些信息包括航班id、付款详细信息、预订截止日期、,

路线、分配的座位、座位计划的观看设施等。

客户可以进行预定,修改以及退票操作。

3.统计模块:可以检索航空公司运营的统计数据,例如

每种类型的飞机数量、每次航班的乘客总数、总收入等。
 

核心代码

数据结构

struct Plane{
	string ID;
	int type;//the type of the plane, 1-P62,2-P124
	string src;//start city
	string dst;//destination city
	string time;//time to set out
	int seatNum;//number of seats in a compartment
	int remainTicket;//the remain ticket of a plane
	int price;//the price of a ticket
	Plane *next;
	Plane(){ next = NULL; }
};


struct Ticket
{
	string passengerName;//the passenger name
	string  planeID;
	int price;
	string expirationDate;//the expiration date of the ticket
	string src;//start city
	string dst;//destination city
	int seatNum; 
	Ticket* next;
	Ticket(){ next = NULL; }
};

struct PlaneHead{
	Plane *head;
	int num;
};

struct TicketHead{
	Ticket *head;
	int num;
};

增加航班

void addNewPlane(PlaneHead *pchead){
	string ID;
	Plane *temp;
	Plane *pc = pchead->head;
	int loopFlag = 0;
	cout << "Add a new plane!" << endl;
	cout << "input the new plane's ID:";
	cin >> ID;
	if (searchByPlaneID(pchead, ID) != NULL){
		cout << "This plane ID is existed! Fail to add a new plane, please retry!" << endl;
		return;
	}
	temp = new Plane;
	temp->ID = ID;
	do{
		cout << "Please input the new plane's type(1 or 2):";
		cin >> temp->type;
		loopFlag = 0;
		if (temp->type != 1 && temp->type != 2){
			cout << "error type!the type should be either 1 or 2,re-input." << endl;
			loopFlag = 1;
		}
	} while (loopFlag);
	do{
		cout << "Please input the new plane's start city:";
		cin >> temp->src;
		cout << "Please input the new plane's destination city:";
		cin >> temp->dst;
		loopFlag = 0;
		if (temp->src == temp->dst){
			cout << "the start city %s and destination %s are the same!,please re-input!" << endl;
			loopFlag = 1;
		}
	} while (loopFlag);
	cout << "Please input the new plane's start time(eg. 12:00 ):";
	cin >> temp->time;
	cout << "Please input the new plane's ticket price:";
	cin >> temp->price;
	if (temp->type == P62)
		temp->seatNum = 6 * 2;
	else
		temp->seatNum = 12 * 4;
	temp->remainTicket = temp->seatNum;
	temp->next = NULL;
	if (pc == NULL)
		pchead->head = temp;
	else
	{
		while (pc->next)
			pc = pc->next;
		pc->next = temp;
	}
	pchead->num++;
	cout << "Add the new plane successfully!" << endl;
}

修改航班

void changePlaneInfo(PlaneHead *pchead){
	int loopFlag = 0;
	string ID;
	char choose;
	Plane *pc;
	cout << "please input the plane's ID you want to change: ";
	cin >> ID;
	pc = searchByPlaneID(pchead, ID);
	if (pc == NULL){
		cout << "The plane ID is not existed!" << endl;
		return;
	}
	cout << "Tips:  you can only change a plane's ticket price,start time,start city and destination city information!" << endl;
	do{
		cout << "The plane " << ID << "'s start city: " << pc->src << " ,you want to change?(y/n) ";
		cin >> choose;
		if (choose == 'Y' || choose == 'y'){
			cout << "Please input the new start city: ";
			cin >> pc->src;
		}
		cout << "The plane " << ID << "'s destination: " << pc->dst << " ,you want to change?(y/n) ";
		cin >> choose;
		if (choose == 'Y' || choose == 'y'){
			cout << "Please input the new destination: ";
			cin >> pc->dst;
		}
		if (pc->src == pc->dst){
			cout << "the start city and destination are the same!" << endl;
			loopFlag = 1;
		}
	} while (loopFlag);
	cout << "The plane " << ID << "'s start time: " << pc->time << " ,you want to change?(y/n) ";
	cin >> choose;
	if (choose == 'Y' || choose == 'y'){
		cout << "Please input the new start time: ";
		cin >> pc->time;
	}
	cout << "The plane " << ID << "'s price: " << pc->price << " ,you want to change?(y/n) ";
	cin >> choose;
	if (choose == 'Y' || choose == 'y'){
		cout << "Please input the new price: ";
		cin >> pc->price;
	}
	cout << "change successfully!" << endl;
}

根据航班ID搜索航班

Plane *searchByPlaneID(PlaneHead *pchead, string ID){
	Plane *pc = pchead->head;
	while (pc)
	{
		if (pc->ID == ID)
			return pc;//find the ID
		pc = pc->next;
	}
	return NULL;
}

由于篇幅有限,此处不在贴代码了。如需要完整代码,可以搜索抖音:天天coding。

私信免费获得完整代码以及技术指导。

功能测试

可以搜索抖音:天天coding,观看完整演示视频。

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mfbz.cn/a/299207.html

如若内容造成侵权/违法违规/事实不符,请联系我们进行投诉反馈qq邮箱809451989@qq.com,一经查实,立即删除!

相关文章

Jmeter相关概念

Jmeter相关概念 jmeter性能指标 Aggregate Report 是 JMeter 常用的一个 Listener&#xff0c;中文被翻译为“聚合报告”。今天再次有同行问到这个报告中的各项数据表示什么意思&#xff0c;顺便在这里公布一下&#xff0c;以备大家查阅。 如果大家都是做Web应用的性能测试&a…

摄像头视频录制程序使用教程(Win10)

摄像头视频录制程序-Win10 &#x1f957;介绍&#x1f35b;使用说明&#x1f6a9;config.json 说明&#x1f6a9;启动&#x1f6a9;关闭&#x1f6a9;什么时候开始录制&#xff1f;&#x1f6a9;什么时候触发录制&#xff1f;&#x1f6a9;调参 &#x1f957;介绍 检测画面变化…

Django HttpResponse 响应对象

目录 一、概述二、测试三、属性和方法四、解读 request 参数 一、概述 所谓 HttpRequest 响应就是服务器返回给客户端的数据&#xff0c;HttpRequest 由程序员自己创建&#xff0c;一般他们通过两种方式来创建。 不使用模板&#xff0c;直接调用 HttpResponse()&#xff0c;返…

Activity启动流程

早就想写这个笔记用于记录这段知识&#xff0c;但是碍于太过庞大所以始终没有进行这段知识的整理 很多博客喜欢画一个时序图展示所有的流程&#xff0c;但是过于庞大&#xff0c;看起来有点吃力&#xff0c;这里我们画多个时序图来展示这个流程 1.app请求AMS启动Activity 在前…

高性能、可扩展、分布式对象存储系统MinIO的介绍、部署步骤以及代码示例

详细介绍 MinIO 是一款流行的开源对象存储系统&#xff0c;设计上兼容 Amazon S3 API&#xff0c;主要用于私有云和边缘计算场景。它提供了高性能、高可用性以及易于管理的对象存储服务。以下是 MinIO 的详细介绍及优缺点&#xff1a; 架构与特性&#xff1a; 开源与跨平台&am…

stm32引脚输入输出设置寄存器操作汇总

下图时正点原子i2c时使用的宏定义 下面的代码是对PA0-PH15的引进行了穷举法代码&#xff0c;使用的时候只需要拷贝三行相应的引脚即可。 //IO方向设置 #define IIC_SDA PAout(0) //SDA #define SDA_IN() {GPIOA->CRL&0XFFFFFFF0;GPIOA->CRL|(u32)8<<0…

复旦MBA :在多元共融中,探寻可持续发展和创新的魅力

复旦MBA的课堂从来不只在复旦校园&#xff1a;从中国到全球&#xff0c;从教室到企业&#xff0c;从每年Global Immersion Program(简称GIP)的美国耶鲁及MIT、UC Berkeley 、英国伦敦商学院、西班牙ESADE商学院、新加坡国立大学、韩国高丽大学等名校寒暑假课程&#xff0c;到Gl…

竞赛练一练 第26期:NOC大赛每日一练,scratch题目刷题第4天,包含答案解析

CIE一级2023.05_找食物 1. 准备工作 (1)添加背景:Jungle; (2)删除小猫角色,添加角色:Dog2、Donut; 2. 功能实现 (1)点击绿旗,小狗的初始位置在舞台左下角,面向右;甜甜圈的初始位置在舞台右下角; (2)等待1秒后,小狗从左下角向右走一段距离,走到甜甜圈边上…

centos通过yum 安装nginx和基本操作

Yum安装Nginx 1、配置Centos 7 Nginx Yum源仓库(注意系统版本要匹配&#xff0c;此步根据环境来确认&#xff0c;不是必须的&#xff09; rpm -Uvh http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm 2、安装Nginx yum install n…

K8s-应用数据

应用数据 1 应用数据解析 k8s应用数据类型和步骤解析 k8s如何使用数据功能 k8s使用各种数据类型的配置 2 应用数据实践 emptyDir实践 资源对象文件内容 apiVersion: v1 kind: Pod metadata:name: sswang-emptydir spec:containers:- name: nginx-webimage: kubernetes-reg…

opencv006图像处理之仿射变换(旋转,缩放,平移)

空间变换中的仿射变换对应着五种变换&#xff0c;平移&#xff0c;缩放&#xff0c;旋转&#xff0c;翻转&#xff0c;错切。而这五种变化由原图像转变到变换图像的过程&#xff0c;可以用仿射变换矩阵进行描述。而这个变换过程可以用一个2*3的矩阵与原图进行相乘得到。关键就是…

性能分析与调优: Linux 实现 off-CPU剖析与火焰图

目录 一、实验 1.环境 2.off-CPU 剖析与火焰图 一、实验 1.环境 &#xff08;1&#xff09;主机 表1-1 主机 主机架构组件IP备注prometheus 监测 系统 prometheus、node_exporter 192.168.204.18grafana监测GUIgrafana192.168.204.19agent 监测 主机 node_exporter192.…

60天零基础干翻C++————初识C++

初识c 命名空间命名空间的定义命名空间的使用 输入输出流缺省参数引用引用定义常量的引用引用的使用场景做函数参数引用做返回值 命名空间 命名空间的定义 在c语言中会有下面问题 上述代码中&#xff0c;全局变量rand 可能会命名冲突&#xff0c;如下图 此时编译失败&…

C++ 中的指针和引用有什么区别?

C 中的指针和引用有什么区别&#xff1f; 在开始前我有一些资料&#xff0c;是我根据网友给的问题精心整理了一份「C的资料从专业入门到高级教程」&#xff0c; 点个关注在评论区回复“888”之后私信回复“888”&#xff0c;全部无偿共享给大家&#xff01;&#xff01;&#…

科技感十足界面模板

科技感界面 在强调简洁的科技类产品相关设计中&#xff0c;背景多数分为&#xff1a;颜色或写实图片两种。 颜色很好理解&#xff0c;大多以深色底为主。强调一种神秘感和沉稳感&#xff0c;同时可以和浅色的文字内容形成很好的对比。 而图片背景的使用&#xff0c;就要求其…

vue实现代码编辑器,无坑使用CodeMirror

vue实现代码编辑器,无坑使用CodeMirror vue实现代码编辑器,使用codemirror5 坑&#xff1a;本打算cv一下网上的&#xff0c;结果发现网上的博客教程都是错的&#xff0c;而且博客已经是几年前的了&#xff0c;我重新看了github上的&#xff0c;发现安装的命令都已经不一样了。我…

HTTP 代理原理及实现(二)

在上篇《HTTP 代理原理及实现&#xff08;一&#xff09;》里&#xff0c;我介绍了 HTTP 代理的两种形式&#xff0c;并用 Node.js 实现了一个可用的普通 / 隧道代理。普通代理可以用来承载 HTTP 流量&#xff1b;隧道代理可以用来承载任何 TCP 流量&#xff0c;包括 HTTP 和 H…

TypeScript基础(二)扩展类型-枚举及其位运算

✨ 专栏介绍 TypeScript是一种由微软开发的开源编程语言&#xff0c;它是JavaScript的超集&#xff0c;意味着任何有效的JavaScript代码都是有效的TypeScript代码。TypeScript通过添加静态类型和其他特性来增强JavaScript&#xff0c;使其更适合大型项目和团队开发。 在TypeS…

self-attention(上)李宏毅

B站视频链接 word embedding https//www.youtube.com/watch?vX7PH3NuYW0Q self-attention处理整个sequence&#xff0c;FC专注处理某一个位置的资讯&#xff0c;self-attention和FC可以交替使用。 transformer架构 self-attention的简单理解 a1-a4可能是input也可以作为中…

Python双端队列的3种实现及应用

概述 双端队列&#xff08;deque&#xff0c;全名double-ended queue&#xff09;是一种具有队列和栈性质的线性数据结构。双端队列也拥有两端&#xff1a;队首&#xff08;front&#xff09;、队尾&#xff08;rear&#xff09;&#xff0c;但与队列不同的是&#xff0c;插入…