飞机订票系统课程设计报告
更新时间:2023-12-21 18:54:01 阅读量: 教育文库 文档下载
数 据 结 构
课 程 设 计 报 告
理论成绩 实践成绩 总成绩
院系: 信息管理学院
专业: 软件工程 班级: 软件Q1141 学号: 11150132 姓名: 王毅 教师: 邓沌华 时间: 2013. 4
一、问题描述
题目:飞机订票系统 题目要求:
(1)可以录入航班情况
(2)可以查询某个航线的情况(如,输入航班号,查询起降时间, 起飞抵达城市,航班票价,票价折扣,确定航班是否满仓); 可以输入起飞抵达城市,查询飞机航班情况;
(3)可以订票,如果该航班已经无票,可以提供相关可选择航班;
(4)可以退票,退票后修改相关数据文件;
(5)当航班信息改变可以修改航班数据文件
二、系统分析及设计
1、 需求分析
系统 乘客
可以录入航班、修改航班信息 乘客按条件查询航班时,系统显示航班信息 乘客订票时,让乘客选择查询航班方式,并显示乘客所需航班的信息 乘客订票时要求乘客输入并保存乘客的相关信息,如果订票失败,显示其它方案 乘客退票,系统修改相应航班信息 查询 订票 退票
2、概要设计
主函数中
flight a[15]; //全局航班数组,存储供测试的航班信息,一共15架飞机,航班信
息可以在所有文件中改变
o_customer co; //全局乘客数组存储已经买了票的顾客信息,顾客信息可以在所有文
件中调用、修改
int k = 15; //全局变量,当前的共有航班的辆数,也可被所有文件调用和修改 供测试的航班情况如下:
○1按航班号查询航班 int number_check() //有此辆航班则返回1,无则返回 0 ○2按终点站查询航班int station_check() //有到该站的航班则返回 1, 无则返回0. ○3订票
int Init(int k); //录入乘客信息, 订票成功返回1,否则返回0.
order_f() //订票函数 {
m = n = 0;
m = number_check();//乘客选择航班号方式的查询航班,m = 1方可订票 n = station_check();//乘客选择终点站查询方法查询航班,n = 1,方可订票
if(Init(0) == 0){}
//按编号查询,只显示一个编号的信息,票存在,但订票失败就给予其它方案 if(Init(k) == 0){} //按照终点站查询,订票失败时给予相应处理方法 } ○4退票
void takeoff(){}
//请用户输入他的证件号,避免同名现象造成的影响 //买票的乘客的信息已经存入全局数组中,直接从数组中找出该乘客信息,然后改变相应航班和乘客的信息
3、详细设计
Customer.cpp//顾客信息源代码
#include
extern flight a[15]; extern int f_no[5]; extern int f;
extern o_customer co;
void getnumber(int i, int length)//获得订单号 {
srand((unsigned)time(NULL));
//随机产生一个订单号,设置一个随机种子,
保证每次产生的订单号不同 co.a[length].t_number= rand()0000000; a[i].total_s --; }
Check.cpp //查询操作源代码
#include\#include
#include\
int Init(int k) { cout<<\请输入姓名: \ cin>>co.a[co.length].c_name; cout<<\请输入证件号: \ cin>>co.a[co.length].c_number; cout<<\请输入订票数量: \ cin>>co.a[co.length].c_total; cout< cout< int f_no[5]; //用来存储按条件查找 的车在数组中的编号 int f ; //用来存储找到车辆的个数 extern flight a[15]; //15辆飞机 int number_check() { int i, n; f = 0; cout<<\请输入航班号: \ cin>>n; cout< f_no[f++] = i; display_flight(a[i]); } } if(f == 0) { //cout<<\无此航班\ return 0; } Order.cpp //订票源代码 #include else { return 1; } } int station_check() { int i; string s; f = 0; cout<<\请输入目的站: \ cin>>s; cout< f_no[f++] = i; display_flight(a[i]); } } if(f == 0) { cout<<\无到达\的航班\ return 0; } else { return 1; } } #include\#include\ int b[5]; void order_f() //订票成功与否都会给出相应提示 { char ch; int i, j, k, m, n; cout<<\请输入查找航班方式: \ cin>>ch; cout< //按编号查询,只显示一个编号的信息,票存在 { cout< //订票失败,数量超过座位余额 { j = 0; for(i = 0; i < 15; i ++) { //cout<<\您还可选择\只将于票数大于等于顾客所需票数的航班列车,其他的具有相同起始站的航班不列出 if(i!=f_no[0] && a[i].s_station == a[f_no[0]].s_station &&a[i].e_station== a[f_no[0]].e_station &&co.a[co.length].c_total<=a[f_no[0]].total_s) { display_flight(a[i]); b[j ++] = i; } } if(j > 0) { if(ch == 'p' && n== 1) //按终点站查询 { int a2; cout< char ch1; int n1; cout<<\您你是否继续订票,继续请安'c',退出请按'q' \ cin>>ch1; if(ch1 == 'c') { cout<<\请输入航班 号: \ cin>>n1; for(i = 0; i < 5; i ++) { if(a[b[i]].f_number==1 && co.a[co.length].c_total <= a[b[i]].total_s ) { co.a[co.length].f_number = b[i]; cout<<\订票成功! 您的订单号为: \ cout< cout< if(Init(k) == 0) { j = 0; for(i = 0; i < 5; i ++) { //cout<<\您还可选择\只将于票数大于 等于顾客所需票数的航 班列车, 其他的具有相同起始站 的航班不列出 if(i!=k && co.a[co.length].c_total <= a[f_no[i]].total_s) { display_flight(a[i]); b[j ++] = i; } } if(j > 0) { char ch1; int n1; cout<<\您你是否继续订票, 继续请安'c',退出请按'q' \ cin>>ch1; if(ch1 == 'c') { cout<<\请输入航班号: \ cout< cin>>n1; for(i = 0; i < 5; i ++) { if(a[b[i]].f_number==n1 && co.a[co.length].c_total<= a[b[i]].total_s ) { co.a[co.length].f_number = b[i]; cout<<\订票成功! 您的订单号为: \ getnumber(b[i], co.length); co.length ++; } } } else { cout<<\欢迎下次使用\ return; } } } } } Takeoff.cpp //退票源代码 #include\ #include\ #include void takeoff()//请用户输入他的证件号,以免出现同名现象 { int i, j, k, m = -1; cout<<\请输入您的证件号: \ cin>>j; cout< while(j != -1) { for(k = 0; k < co.length; k ++) { if(co.a[k].c_number == j) m = k; } if(m > -1) { //cout< 三. 系统实现 1. 完整源代码(见文档末尾) 2. 输出界面: 查询、订票、退票操作截图: 四.设计总结 飞机订票系统主要实现的功能是:查询,订票,退票。其中用到了全局变量,数组等一系列知识,订票是该订票系统最难写的部分,要调用大量的函数。订票系统中数据量很大,写代码精力要高度集中。另外我发现了一个很好的编程习惯,写一个函数,或一个文件时,就编译一次;不能等到代码写完再去编译,当遇到代码量大,函数很多的代码时,小差错不容易被发现,而且报错的位置可能乱指,以后要逐个编译。另外用多文件写代码,思路清晰,函数分明,容易根据函数名找到相应的函数。 flight.h #include using namespace std; #ifndef _flight_h_ #define _flight_h_ typedef struct Flight { int f_number; string start_t; string end_t; float price; //航班信息 //航班号 //起飞时间 //到达时间 //票价 int total_seat; //可确定航班是否满仓 int total_s; //当前余票数 string s_station; //起点站 string e_station; //终点站 //city *h; 信息,是一个单链表(可以做火车订票系统) }flight; #endif Customer.h #include\#ifndef _customer_h_ #define _customer_h_ typedef struct Customer { string c_name; //顾客姓名 int c_number; //证件号 #include extern flight a[15]; extern int f_no[5]; extern int f; extern o_customer co; void getnumber(int i, int length)//获得订单号 { srand((unsigned)time(NULL)); //随机产生一个订单号,设置一个随机种子 ,保证每次产生的订单号不同 co.a[length].t_number = rand()0000000; a[i].total_s --;} int Init(int k) { cout<<\请输入姓名: \ cin>>co.a[co.length].c_name; cout<<\请输入证件号: \ int c_total; //订票数量 int t_number; //订单编号 int f_number; //所定航班在数组中的位置 //int o_number; }customer; typedef struct O_customer //存放买过票的乘客的信息 { customer a[100]; int length; //当前买过票的总人数 }o_customer; int Init(int k); //录入顾客信息 void getnumber(int i, int length); #endif customer.cpp cin>>co.a[co.length].c_number; cout<<\请输入订票数量: \ cin>>co.a[co.length].c_total; cout< cout< ndl; co.length ++; } else { cout<<\订票失败,余票不足\ return 0; } return 1; } Check.h #ifndef check_h #define check_h int number_check(); int station_check(); #endif check.cpp #include\#include #include\ int f_no[5]; //用来存储按条件查找的车在数组中的编号 int f ; //用来存储找到车辆的个数 extern flight a[15]; int number_check() { int i, n; f = 0; int station_check() { cout<<\请输入航班号: \ cin>>n; int i; cout< else } { } return 1; input_data.h #ifndef input_data_h #define input_data_h void Input_data(); #endif input_data.cpp #include extern flight a[50]; extern int k; //记录当前航班的辆数 //先建立15辆航班信息 int f[15] = {110, 111, 112, 113, 114, 115, 116, 117, 118 ,119, 120, 121, 122,123, 124}; string sa[15] = {\武汉\云梦\汉口\武昌\武昌\北京\上海\天津\十堰\山东\\武汉\武汉\北京\上海\天津\起始站 string st[15] = {\\\\\\\\\\\时间 string et[15] = {\\到站时间 string se[15] = {\信阳\太原\哈尔滨\南京\重庆\大连\吉林\成都\西安\北京\信阳\信阳\大连\吉林\成都\终点站 int ts[15] = {255, 230, 250, 150, 120, 130, 110, 90, 95, 120, 130, 120, 150, 160, 200};//总共座位数 int tss[15] = {255, 230, 250, 150, 120, 130, 110, 90, 95, 120, 130, 120, 150, 160, 200};//当前可供预定的票数 float p[15] = {39, 230, 150, 130, 230, 124, 135, 220, 113, 130, 39, 39, 124, 135, 220}; void Input_data() a[i].end_t = et[i]; { a[i].total_seat = ts[i]; int i; a[i].total_s = tss[i]; for(i = 0; i < 15; i ++) a[i].price = p[i]; { } a[i].f_number = f[i]; } a[i].s_station = sa[i]; a[i].e_station = se[i]; void getdata() //录入新航班 a[i].start_t = st[i]; { int i = 1; while(i != 0) { cout<<\请依次输入:航班号、起点站、 cin>>a[k].e_station; cin>>a[k].start_t; cin>>a[k].end_t ; cin>>a[k].total_seat; 终点站、起飞时间、到站时间、 仓位、票价\ cin>>a[k].f_number; cin>>a[k].s_station; order.h #ifndef order_h #define order_h #include\ void order_f(); //订票成功 #endif order.cpp #include extern flight a[15]; extern int f_no[5]; extern int f; o_customer co; int b[5]; void order_f() //订票成功与否都会给出相应提示 { char ch; int i, j, k, m, n; cout<<\请输入查找航班方式: \ cin>>ch; cout< cin>>a[k].price; } } if(ch == 'n' && m == 1) //按编号查询,只显示一个编号的信息,票存在 { cout< //订票失败,数量超过座位余额 { j = 0; for(i = 0; i < 15; i ++) { //cout<<\您还可选择\只将于票数大于等于顾客所需票数的航班列车,其他的具有相同起始站的航班不列出 if(i!=f_no[0] && a[i].s_station == a[f_no[0]].s_station &&a[i].e_station== a[f_no[0]].e_station &&co.a[co.length].c_total<=a[f_no[0]].total_s) { display_flight(a[i]); b[j ++] = i; } } if(j > 0) { char ch1; int n1; cout<<\您你是否继续订 票,继续请安'c',退出请 按'q' \ cin>>ch1; if(ch1 == 'c') { cout<<\请输入航班号: \ cin>>n1; for(i = 0; i < 5; i ++) { if(a[b[i]].f_number==1 && co.a[co.length].c_total <= a[b[i]].total_s ) { co.a[co.length].f_number = b[i]; cout<<\订票成功! 您的订单号为: \ cout< return; } } } } if(ch == 'p' && n== 1) { int a2; cout< } if(Init(k) == 0) { j = 0; for(i = 0; i < 5; i ++) { //cout<<\您还可选择\ 只将于票数大于等于顾客所需票数的航班 列车,其他的具有相同起始站的航班不列出 if(i!=k && co.a[co.length].c_total <= a[f_no[i]].total_s) { display_flight(a[i]); b[j ++] = i; } } if(j > 0) { char ch1; int n1; cout<<\您你是否继续订票,继续请安'c',退出请按'q' \ cin>>ch1; if(ch1 == 'c') { cout<<\请输入航班号: \cout< cin>>n1; for(i = 0; i < 5; i ++) { if(a[b[i]].f_number==n1 && co.a[co.length].c_total<= a[b[i]].total_s ) { { co.a[co.length].f_number = b[i]; cout<<\欢迎下次使用\ cout<<\订票成功! 您的订单号为: \ return; getnumber(b[i], co.length); } co.length ++; } } } } } } else } takeoff.h #include\#define takeoff_h #include\void takeoff();//请用户输入航班编号,取消 航班 #ifndef takeoff_h #endif takeoff.cpp #include\#include\#include extern flight a[15]; extern o_customer co; void takeoff()//请用户输入他的证件号,以免出现同名现象 { int i, j, k, m = -1; cout<<\请输入您的证件号: \ cin>>j; cout< cout<<\输入过大,请重新输入\ cin>>i; } co.a[m].c_total = co.a[m].c_total - i; a[co.a[m].f_number].total_s = a[co.a[m].f_number].total_s - i; cout<<\退票成功!\ j = -1; } else { cout<<\你的证件号有误\ cout<<\继续退票请重新输入证件号, 退出请按-1: \ cin>>j; cout< interface.h #ifndef _interface_h_ #define _interface_h_ void dis_interface(); #endif interface.cpp #include \#include void dis_interface() { cout<<\主菜单:查询、订票、退票、改签\ cout<<\ cout< display_flight.h #ifndef display_flight_h #define display_flight_h #include\ void display_flight(flight a); void display(); #endif display_flight.cpp #include\#include void display_flight(flight a) { cout< < void display() { cout<<\航班号\\t\起点站\\t\终点站\\t\飞时\\t\到站\\t\仓位\\t\票价\\t\折扣\\t\} co.length = 0; main.cpp #include\ Input_data(); #include\ dis_interface(); #include\ char ch; #include\ int i; #include\ #include\ #include\ customer *c1 = NULL; #include\ customer *c2 = NULL; #include while(ch != 'q') flight a[15]; //存储供测试的航班信息,一共 { 15架飞机 switch(ch) extern o_customer co;//存储已经买了票的顾 { 客信息 int k = 15; case'n': i = number_check(); break; int main() case'p': i = station_check(); { break; case'o':order_f(); break; case't':takeoff(); break; } cout< cout<<\是否继续操作 ,请根据菜单输入: \ cin>>ch; cout<
正在阅读:
飞机订票系统课程设计报告12-21
《中医药法》知识竞赛竞答题09-30
223团中学3月份二年级学生优秀写话作品12-20
电动自行车市场营销策划04-18
沪教版六年级上《科学》目录(最新整理)07-26
第4课 经济大危机导学案07-29
礼泉县小城镇建设调研报告06-06
如何提高撰写调研报告的能力和素质06-07
尤克里里五个音阶型 四线图解一看就会 精选十首名曲单音简谱入门05-25
花样跳绳社团活动计划(最新)03-17
- exercise2
- 铅锌矿详查地质设计 - 图文
- 厨余垃圾、餐厨垃圾堆肥系统设计方案
- 陈明珠开题报告
- 化工原理精选例题
- 政府形象宣传册营销案例
- 小学一至三年级语文阅读专项练习题
- 2014.民诉 期末考试 复习题
- 巅峰智业 - 做好顶层设计对建设城市的重要意义
- (三起)冀教版三年级英语上册Unit4 Lesson24练习题及答案
- 2017年实心轮胎现状及发展趋势分析(目录)
- 基于GIS的农用地定级技术研究定稿
- 2017-2022年中国医疗保健市场调查与市场前景预测报告(目录) - 图文
- 作业
- OFDM技术仿真(MATLAB代码) - 图文
- Android工程师笔试题及答案
- 生命密码联合密码
- 空间地上权若干法律问题探究
- 江苏学业水平测试《机械基础》模拟试题
- 选课走班实施方案
- 订票
- 飞机
- 课程
- 报告
- 设计
- 系统
- 服务器CPU和普通CPU的区别
- 对建筑工程施工技术管理思考论文
- 金属和金属材料知识点归纳总结
- HXN5型内燃机车“油水互窜”故障浅析
- 国培计划农村中小学骨干教师远程培训项目 - 图文
- 解读最适合上班族的理财方式
- 中小学校长竞聘面试题精选
- 小学语文第八册第一单元检测卷
- 偏析法高纯铝项目可行性研究报告 - 图文
- 高中英语(外研版)选修8第3-4模块基础训练与能力测试
- STM32的CAN总线+J1939数据格式说明
- 教你水果要怎么洗才干净
- 百色学院参加2008年全国大学生英语竞赛广西赛区比赛获奖情况通报
- 2014-2015中国大学排行榜
- 人教版高中英语选修6课本练习配套参考答案-精编 - 图文
- 3.8牛顿第二定律的应用(五)连接体、叠加体问题
- 2014年竣工监理工作总结 50356
- 身体素质理论讲稿
- 初一下册期中测试(相交线和平行线、三角形和全等三角形)
- 班主任70个临场应变技巧