航班售票系统设计与实现

这是一个关于航班售票系统的实现,包括时间类、乘客类、航班类的定义和实现,支持航班信息的增删改查、订票、退票、查询起飞降落时间等功能。系统采用C++编程,涉及类的定义、重载运算符、文件操作等概念。
摘要由CSDN通过智能技术生成

一、基本功能要求:

1)假设该民航有若干航班,要求实现增加航班和取消某个航班的,修改航

班功能。

2)查询:根据用户提出的终点站查询航班号、售票情况等航班信息;也可

根据航班号,列出该航班已订票的乘客名单。

3)订票:根据航班号为客户订票,如该航班有余票,则为客户订票;如该

航班已满员,则显示相应信息。

4)退票:按乘客要求退出已预定的机票。

5)飞行时刻查询:显示航班的起飞降落时间。

提示:

航班信息:航班号、到达港、总座位数、余票额、乘客名单;

乘客信息:乘客姓名、证件号码、座位号。

技术要求:

1、使用类;

2、使用向量

3、数据存储在文件中。

4、DOS 版 / WINDOWS 版




/文件名称:Time.h
/功能介绍:定义了时间类
时间信息:时,分,秒;
作者:lonely
///
#include<iostream>
using namespace std;
class Time
{
protected:
int hour;//0~23
int minute;//0~59
int second;//0~59
public:
int getHour(){return hour;}
int getminute(){return minute;}
int getsecond(){return second;}
friend ostream &operator<<(ostream& output,Time &p);//重载函数《
friend istream &operator>>(istream& input,Time &p);//重载函数>>
Time():hour(0),minute(0),second(0){}//构造函数
Time(int h,int m,int s):hour(h),minute(m),second(s){}//构造函数
Time &operator=(const Time &p);//重载函数=
bool operator>(const Time&)const;//重载函数>
};

















/文件名称:Time.cpp
/功能介绍:实现了时间类成员
作者:lonely
///
#include"Time.h"
#include<iostream>
using namespace std;
重载函数:<<//
ostream &operator<<(ostream &output,Time &p)
{
output<<p.hour<<":"<<p.minute<<":"<<p.second;
return output;
}
//重载函数:>>//
istream &operator>>(istream &input,Time &p)
{
input>>p.hour>>p.minute>>p.second;
while(p.second<0||p.second>60)
{
cout<<"输入的秒数有误,请重新输入:";
input>>p.second;
}
if(p.second==60)
{
p.second=0;
p.minute++;
}
while(p.minute<0||p.minute>60)
{
cout<<"输入的分钟有误,请重新输入:";
input>>p.minute;
}
if(p.minute==60)
{
p.minute=0;
p.hour++;
}
while(p.hour<0||p.hour>24)
{
cout<<"输入的分钟有误,请重新输入:";
input>>p.hour;
}
if(p.hour==24)
p.hour=0;
return input;
}
//重载函数:=//
Time &Time::operator=(const Time &p)
{
hour=p.hour;
minute=p.minute;
second=p.second;
return *this;
}
//重载函数:>//
bool Time::operator>(const Time &right)const
{
if(hour>right.hour)
return true;
    else if(hour==right.hour&&minute>right.minute)
return true;
else if(hour==right.hour&&minute==right.minute&&second>right.second)
return true;
return false;
}

















/文件名称:Cnode.h
/功能介绍:定义了乘客类
乘客信息:乘客姓名、证件号码、座位号。
作者:lonely
///
#pragma once
#include<string>
using namespace std;
class Cnode
{
public:
Cnode();//构造函数
Cnode(string n,string id,int seat);//构造函数
//friend ostream &operator<<(ostream& output,Cnode &p);//重载函数:<<
//friend istream &operator>>(istream& input,Cnode &p);//重载函数:>>
string getName(){return name;}
int getSeat(){return seatno;}
string getIDcard(){return idcard;}
private:
string name;//乘客姓名
string idcard;//证件号码
int seatno;//座位号
};





















/文件名称:Cnode.cpp
/功能介绍:实现了乘客类成员
作者:lonely
///
#include"Cnode.h"
#include<iostream>
using namespace std;
Cnode::Cnode()//构造函数
{
name="\n";
idcard="\n";
seatno=0;
}
Cnode::Cnode(string n,string id,int seat)//构造函数
{
name=n;
idcard=id;
seatno=seat;
}
/*ostream &operator<<(ostream &output,Cnode &p)//重载函数:<<
{
cout<<"乘客姓名:"<<p.name<<endl;
cout<<"证件号码:"<<p.idcard<<endl;
cout<<"座位号:"<<p.seatno<<endl;
return output;
}*/
/*istream &operator>>(istream &input,Cnode &p)//重载函数:>>
{
cin>>p.name;
cin>>p.idcard;
cin>>p.seatno;
return input;
}*/





















/文件名称:Pnode.h
/功能介绍:定义了航班类
航班基本信息:航班号、到达港、总座位数、余票额、乘客名单;
作者:lonely
///
#pragma once
#include"Cnode.h"
#include"Time.h"
#include<string>
#include<vector>
#include<iostream>
using namespace std;
class Flight:public Time//航班类,公有继承时间类
{
private:
int no;//航班编号
string destin;//到达港
int limit,rest;//总座位数,余票额
vector<Cnode> cname;//乘客名单向量
Time fly;//起飞时间
Time reach;//到达时间
public:
Flight();//公有函数
Flight(int n,string s,int l,Time f,Time r);//公有函数
Flight(int n,string s,int l,int rt,Time f,Time r);//公有函数
int getNo(){return no;}
void setNO(int n){no=n;}
string getDestin(){return destin;}
void setDestin(string de){destin=de;}
int getLimit(){return limit;}
void setLimit(int l){limit=l;}
int getRest(){return rest;}
void setRest(int r){rest=r;}
航空客运订票系统 特点:超详细的JAVA代码注释,代码保护性,无论输入什么都不会崩溃; 【问题描述】航空客运订票的业务活动包括:查询航线、添加航班,客票预订和办理退票等七大功能,已实现操作文件。试设计一个航空客运订票系统,以使上述业务可以借助计算机来完成。 【基本要求】 (1)每条航线所涉及的信息有:终点站名、航班号、飞机号、飞行周日(星期几)、乘员定额、余票量、已订票的客户名单(包括姓名、订票量、舱位等级1,2或3)以及等候替补的客户名单(包括姓名、所需票量); (2)系统能实现的操作和功能如下: ①录入:可以录入航班情况,全部数据可以只放在内存中,最好存储在文件中; ②查询航线:根据旅客提出的终点站名输出下列信息:航班号、飞机号、星期几飞行,最近一天航班的日期和余票额; ③承办订票业务:根据客户提出的要求(航班号、订票数额)查询该航班票额情况,若尚有余票,则为客户办理订票手续,输出座位号;若已满员或余票额少于订票额,则需重新询问客户要求。若需要,可登记排队候补; ④承办退票业务:根据客户提供的情况(日期、航班),为客户办理退票手续,然后查询该航班是否有人排队候补,首先询问排在第一的客户,若所退票额能满足他的要求,则为他办理订票手续,否则依次询问其他排队候补的客户。 【测试数据】由读者自行指定。 【实现提示】两个客户名单可分别由线性表和队列实现。为查找方便,已订票客户的线性表应按客户姓名有序,并且,为插入和删除方便,应以链表作存储结构。由于预约人数无法预计,队列也应以链表作存储结构。整个系统需汇总各条航线的情况登录在一张线性表上,由于航线基本不变,可采用顺序存储结构,并按航班有序或按终点站名有序。每条航线是这张表上的一个记录,包含上述8个域、其中乘员名单域为指向乘员名单链表的头指针,等候替补的客户名单域为分别指向队头和队尾的指针。 【选作内容】当客户订票要求不能满足时,系统可向客户提供到达同一目的地的其他航线情况。读者还可充分发挥自己的想象力,增加你的系统的功能和其他服务项目 I/O流操作时用到了GSON,解压即可看到,如果发现报错,读者可以配置一下Gson的路径,在属性,JAVA构建路径中删除原有的三个GSON库,添加外部,下载的GSON库。如果不用可以将Main类中new ReadFlightLine();注释掉即可。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值