航班订票系统.docx
《航班订票系统.docx》由会员分享,可在线阅读,更多相关《航班订票系统.docx(30页珍藏版)》请在冰豆网上搜索。
![航班订票系统.docx](https://file1.bdocx.com/fileroot1/2023-2/4/b174e62c-45a1-41eb-89cb-e0b8a6725894/b174e62c-45a1-41eb-89cb-e0b8a67258941.gif)
航班订票系统
课程设计题目航班订票系统
课程设计目的
本课程设计的目的就是要达到理论与实际应用相结合,使同学们能够根据数据对象的特性,学会数据组织的方法,能把现实世界中的实际问题在计算机内部表示出来,并培养基本的、良好的程序设计技能。
任务:
通过此系统可以实现如下功能:
1)、录入:
可以录入航班情况(数据可以存储在一个数据文件中,数据结构、具体数据自定)
2)、查询:
可以查询某个航线的情况(如,输入航班号,查询起降时间,起飞抵达城市,航班票价,票价折扣,确定航班是否满仓);
可以输入起飞抵达城市,查询飞机航班情况;
3)、订票:
(订票情况可以存在一个数据文件中,结构自己设定)
可以订票,如果该航班已经无票,可以提供相关可选择航班;
4)、退票:
可退票,退票后修改相关数据文件;
客户资料有姓名,证件号,订票数量及航班情况,订单要有编号。
5)、修改航班信息:
当航班信息改变可以修改航班数据文件
要求:
根据以上功能说明,设计航班信息,订票信息的存储结构,设计程序完成功能;
界面要求:
有合理的提示,每个功能可以设立菜单,根据提示,可以完成相关的功能要求。
存储结构:
学生自己根据系统功能要求自己设计。
请在最后的上交资料中指明你用到的存储结构;
一、测试数据:
要求使用1、全部合法数据;2、整体非法数据;3、局部非法数据。
二、进行程序测试,以保证程序的稳定。
测试数据及测试结果请在上交的资料中写明。
系统需求分析
随着经济全球化的推进以及企业激烈的竞争,各大机场订票系统已经越来越不能适应人们日常出行的局面,所以我们现在需要一个检索迅速、查找方便、易修改功能齐全方便的系统来适应我们的需求。
问题的提出:
为了减少人工工作量,提高工作效率,使机场管理员的工作更加有效的进行。
系统总体设计
系统设计目标
本文研究开发的航空订票系统用于完成航空订票工作,有以下三个方面的目标:
【1】支持航空管理公司更加便捷的管理
【2】支持航空公司高效率的满足人们空行需求,包括与班机有关的订票,退票,查询等功能。
【3】支持航空公司随时增加或者是删除航班信息
开发设计思想
基于以上系统设计目标,本文在开发人事管理信息系统时遵循了以下开发设计思想:
●采用现有的软硬件环境及先进的管理系统开发方案,从而达到充分利用现有资源,提高系统开发水平和应用效果的目的。
●尽量达到操作过程中的直观、方便、实用、安全等要求。
●系统采用模块化程序设计方法,既便于系统功能的各种组合和修改,又便于未参与开发的技术维护人员补充、维护。
●系统应具备数据库维护功能,及时根据用户需求进行数据的添加、删除、修改、等操作。
系统功能模块设计
本系统分为六个模块:
增加航班模块、浏览航班模块、查找航班模块、航班排序模块、订票模块、退票模块。
得到如图所示系统功能模块图。
系统功能模块图
算法思想描述
主界面程序图
系统录入程序图:
查询系统程序图:
订票系统程序图:
退票系统程序图:
程序源代码
#include
#include
#include
#include
classFlight//航班类
{
charnum[20];//航班号
chars[20];//出发站
chare[20];//到达站
chart[20];//起飞时间
intfee;//票价
intsum;//总票数
intn;//剩余票数
Flight*next;//下个航班
public:
Flight(){}
~Flight(){}
char*getnu(){returnnum;}
voidsetnu(char*n){strcpy(num,n);}
char*gets(){returns;}
voidsets(char*s){strcpy(this->s,s);}
char*gete(){returne;}
voidsete(char*e){strcpy(this->e,e);}
char*gett(){returnt;}
voidsett(char*t){strcpy(this->t,t);}
intgetf(){returnfee;}
voidsetf(intf){fee=f;}
intgetsu(){returnsum;}
voidsetsu(ints){sum=s;}
intgetn(){returnn;}
voidsetn(intn){this->n=n;}
Flight*getnext(){returnnext;}
voidsetnext(Flight*n){next=n;}
};
classClient//乘客类
{
charnum[20];//航班号
charname[20];//乘客姓名
intn;//所购票数
Client*next;
public:
Client(){}
~Client(){}
char*getna(){returnname;}
voidsetna(char*n){strcpy(name,n);}
char*getnu(){returnnum;}
voidsetnu(char*n){strcpy(num,n);}
intgetn(){returnn;}
voidsetn(intn){this->n=n;}
Client*getnext(){returnnext;}
voidsetnext(Client*n){next=n;}
};
classmanage//管理类
{
private:
Flight*head1;//航班头指针
Flight*last1;
Client*head2;//乘客头指针
Client*last2;
public:
manage(){}
~manage(){}
voidini();
voidnewf();
voidbuy();
voidshow1();
voidshow2();
voidmodify();
voiddel();
voiddelall();
voidbaClient();
voidquery1();
voidquery2();
voidsave();
voidrun();
};
voidmanage:
:
ini()
{
head1=last1=NULL;head2=last2=NULL;
ifstreamrf("Flighte.txt",ios:
:
out|ios:
:
nocreate,filebuf:
:
openprot);
if(rf.fail())cout<<"\n\n提示,文件读取失败!
";
else
{
intn=0;//得到个数
rf.read((char*)&n,sizeof(n));//得到航班个数
for(inti=0;i{
Flight*p1=newFlight;
rf.read((char*)p1,sizeof(Flight));
p1->setnext(NULL);
if(head1==NULL)head1=last1=p1;
else{last1->setnext(p1);last1=p1;}
}
cout<<"\n初始化"<
";
rf.read((char*)&n,sizeof(n));//得到乘客个数
for(i=0;i{
Client*p2=newClient;
rf.read((char*)p2,sizeof(Client));
p2->setnext(NULL);
if(head2==NULL)head2=last2=p2;
else{last2->setnext(p2);last2=p2;}
}
cout<<"\n初始化"<
";
}
rf.close();
}
voidmanage:
:
newf()
{
Flight*p;
p=newFlight;
cout<<"\n录入航班信息\n";
charc[50];
cout<<"请输入航班号\n";
cin>>c;
p->setnu(c);
cout<<"请输入起始地\n";
cin>>c;
p->sets(c);
cout<<"请输入目的地\n";
cin>>c;
p->sete(c);
cout<<"请输入起飞日期(年/月/日/时:
分)\n";
cin>>c;
p->sett(c);
cout<<"\n请输入机票金额\n\n";
intn;
cin>>n;p->setf(n);
cout<<"\n请输入机票总数\n\n";
cin>>n;p->setsu(n);
p->setn(n);
p->setnext(NULL);
if(head1){last1->setnext(p);last1=p;}
elsehead1=last1=p;
cout<<"\n新航班创建成功\n\n";
}
voidmanage:
:
buy()
{
if(head1==NULL){cout<<"提示:
无航班信息!
\n";return;}
cout<<"\n\n\n\n购买机票\n";
charc[50];
cout<<"\n请输入航班号\n";
cin>>c;
inty=1;
Flight*p=head1;
while(p)
{
if(strcmp(p->getnu(),c)==0){y=0;break;}
p=p->getnext();
}
if(y){cout<<"\n错误,无此航班号!
";return;}
if(p->getn()<=0){cout<<"\n提示,此航班票已经售完!
\n";return;}
cout<<"\n|---------------------------------------------------------------------------|";
cout<<"\n航次:
"<getnu()<<"起飞时间:
"<gett()<<"总票数:
"<getsu();
cout<<"\n航线:
"<gets()<<"--->"<gete()<<"票价:
"<getf()<<"剩余票数:
"<getn();
cout<<"\n|---------------------------------------------------------------------------|\n";
Client*p1;
p1=newClient;
p1->setnext(NULL);
p1->setnu(c);
cout<<"\n-------------------------请进行购票登记---------------------------";
cout<<"\n请输入姓名:
\n";
cin>>c;
p1->setna(c);
loop:
cout<<"\n请输入购买票数:
\n";
intn;
cin>>n;
if(n>p->getn())
{
cout<<"\n提示,您最多只能购买"<getn()<<"张票!
";
gotoloop;
}
p1->setn(n);
p->setn(p->getn()-n);
if(head2==NULL)head2=last2=p1;
else{last2->setnext(p1);last2=p1;}
cout<<"\n------------买票成功,您需要付款:
"<getf()*p1->getn()<<"元-----------------";
}
voidmanage:
:
show1()
{
if(head1==NULL){cout<<"航班信息为空!
\n\n";return;}
Flight*p=head1;
cout<while(p)
{
cout<<"\n航次:
"<getnu()<<"起飞时间:
"<gett()<<"总票数:
"<getsu();
cout<<"\n航线:
"<gets()<<"--->"<gete()<<"票价:
"<getf()<<"剩余票数:
"<getn();
cout<<"\n|---------------------------------------------------------------------------|\n";
p=p->getnext();
}
}
voidmanage:
:
show2()
{
if(head2==NULL){cout<<"乘客信息为空!
\n\n";return;}
Client*p=head2;
cout<while(p)
{
cout<<"\n姓名:
"<getna()<<"航班号:
"<getnu()<<"所购票数:
"<getn();
cout<<"\n|---------------------------------------------------------------------------|\n";
p=p->getnext();
}
}
voidmanage:
:
modify()
{
cout<Flight*p=head1;
charm[20];
inty=1;
cout<<"\n\n请输入要修改的航班\n\n";
cin>>m;
while(p)
{
if(strcmp(p->getnu(),m)==0)
{
y=0;
cout<<"\n请修改起始地\n\n";
cin>>m;
p->sets(m);
cout<<"\n请修改目的地\n\n";
cin>>m;
p->sete(m);
cout<<"\n请修改登机时间(年/月/日/时:
分)\n\n";
cin>>m;p->sett(m);
cout<<"\n请修改机票价格\n\n";
intn;
cin>>n;
p->setf(n);
loop:
cout<<"\n请修改机票总数\n";
cin>>n;
if(ngetsu()-p->getn()){cout<<"\n错误,机票总数必须>=已售机票数!
\n";gotoloop;}
p->setn(n-(p->getsu()-p->getn()));
p->setsu(n);
}
p=p->getnext();
}
if(y)
cout<<"\n错误,无此航班号!
";
else
cout<<"\n航班修改成功!
";
}
voidmanage:
:
del()
{
if(head1==NULL){cout<<"\n\n提示:
无航班信息!
";return;}
cout<Flight*temp,*p=head1;
charm[20];
inty=1;
loop:
cout<<"\n\n请输入要删除的航班\n\n";
cin>>m;
if(strcmp(head1->getnu(),m)==0){
if(head1->getsu()!
=head1->getn()){cout<<"\n该航班已经开始售票,不能取消!
\n\n";gotoloop;}
y=0;
temp=head1;
head1=head1->getnext();
}
else
while(p->getnext())
{
if(strcmp(p->getnext()->getnu(),m)==0)
{
if(p->getnext()->getsu()!
=p->getnext()->getn()){cout<<"\n该航班已经开始售票,不能取消!
\n\n";gotoloop;}
y=0;
temp=p->getnext();
p->setnext(temp->getnext());
break;
}
p=p->getnext();
}
if(y)
cout<<"\n错误,无此航班号!
";
else
{deletetemp;cout<<"\n\n操作成功!
";}
}
voidmanage:
:
delall()
{
cout<Flight*p1=head1;
while(p1)
{
Flight*temp1=p1->getnext();
deletep1;
p1=temp1;
}
head1=last1=NULL;
Client*p2=head2;
while(p2)
{
Client*temp2=p2->getnext();
deletep2;
p2=temp2;
}
head2=last2=NULL;
cout<<"\n\n信息清空成功!
";
}
voidmanage:
:
query1()
{
charc;
charm[30];
if(head1==NULL){cout<<"\n\n提示:
无航班信息!
";return;}
do
{
cout<cout<cout<cout<Flight*p=head1;
cin>>c;
switch(c)
{
case'1':
{
inty=1;
cout<<"\n\n请输入要查找的起始地\n\n";
cin>>m;
while(p)
{
if(strcmp(p->gets(),m)==0)
{
cout<<"\n|-----------------------------------------------------------------------------|";
cout<<"\n航次:
"<getnu()<<"起飞时间:
"<gett()<<"总票数:
"<getsu();
cout<<"\n航线:
"<gets()<<"--->"<gete()<<"票价:
"<getf()<<"剩余票数:
"<getn();
cout<<"\n|---------------------------------------------------------------------------|\n";
y=0;
}
p=p->getnext();
}
if(y)cout<<"失败,您查询的航班不存在!
\n\n";
}
break;
case'2':
{
inty=1;
cout<<"\n\n请输入要查找的目的地\n\n";
cin>>m;
while(p)
{
if(strcmp(p->gete(),m)==0)
{
cout<<"\n航次:
"<getnu()<<"起飞时间:
"<gett()<<"总票数:
"<getsu();
cout<<"\n航线:
"<gets()<<"--->"<gete()<<"票价:
"<getf()<<"剩余票数:
"<getn();
cout<<"\n|---------------------------------------------------------------------------|\n";
y=0;}
p=p->getnext();
}
if(y)cout<<"失败,您查询的航班不存在!
\n\n";
}
break;
case'3':
break;
}
}
while(c!
='c'&&c!
='C');
}
voidmanage:
:
query2()
{
if(head1==NULL){cout<<"\n\n提示:
无航班信息!
";return;}
charc,m[20];
do
{
cout<cout<cout<cout<cin>>c;
switch(c)
{
case'1':
{
Flight*p1=head1;
Client*p2=head2;
inty1=1,y2=1;
cout<<"\n\n请输入要查找的航班号\n\n";
cin>>m;
while(p1)
{
if(strcmp(p1->getnu(),m)==0)
{
y1=0;
cout<<"\n|---------------------------------------------------------------------------|\n";
cout<<"\n航次:
"<getnu()<<"起飞时间:
"<gett()<<"总票数:
"<getsu();
cout<<"\n航线:
"<gets()<<"--->"<gete()<<"剩余票数:
"<getn();
cout<<"\n|---------------------------------------------------------------------------|\n";
}
p1=p1->getnext();
}
if(y1)cout<<"\n失败,您查询的航班不存在!
\n";
else{
while(p2)
{
if