飞机订票系统课程设计报告(3)

2020-02-20 17:49

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 #include #include #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<>s; if(a[i].f_number == n) cout<

else } { } return 1; input_data.h

#ifndef input_data_h #define input_data_h

void Input_data(); #endif

input_data.cpp #include #include\#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 #include\#include\#include\#include\#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<>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 ) {


飞机订票系统课程设计报告(3).doc 将本文的Word文档下载到电脑 下载失败或者文档不完整,请联系客服人员解决!

下一篇:建筑工程技术质量目标管理责任书

相关阅读
本类排行
× 注册会员免费下载(下载后可以自由复制和排版)

马上注册会员

注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信: QQ: