航空公司管理系统(迷你版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,观看完整演示视频。

  • 18
    点赞
  • 24
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值