ImageVerifierCode 换一换
格式:DOCX , 页数:67 ,大小:352.73KB ,
资源ID:28585748      下载积分:3 金币
快捷下载
登录下载
邮箱/手机:
温馨提示:
快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。 如填写123,账号就是123,密码也是123。
特别说明:
请自助下载,系统不会自动发送文件的哦; 如果您已付费,想二次下载,请登录后访问:我的下载记录
支付方式: 支付宝    微信支付   
验证码:   换一换

加入VIP,免费下载
 

温馨提示:由于个人手机设置不同,如果发现不能下载,请复制以下地址【https://www.bdocx.com/down/28585748.html】到电脑端继续下载(重复下载不扣费)。

已注册用户请登录:
账号:
密码:
验证码:   换一换
  忘记密码?
三方登录: 微信登录   QQ登录  

下载须知

1: 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。
2: 试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。
3: 文件的所有权益归上传用户所有。
4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
5. 本站仅提供交流平台,并不能对任何下载内容负责。
6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

版权提示 | 免责声明

本文(车辆管理系统实验报告.docx)为本站会员(b****1)主动上传,冰豆网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知冰豆网(发送邮件至service@bdocx.com或直接QQ联系客服),我们立即给予删除!

车辆管理系统实验报告.docx

1、车辆管理系统实验报告 成绩: C+程序设计实践报告专 业: 软件工程 班 级: 学 号: 姓 名: 日期:2016年 06月 26日一、设计目的(1)要求学生能够熟练掌握C+语言的基本知识和技能。(2)基本掌握面向对象程序设计的基本思路和方法。(3)能够利用所学的基本知识和技能,解决简单的面向对象程序设计问题。所做题目:4题:车辆管理系统主要负责各种车辆的常规信息管理工作。系统中的车辆主要有大客车、小轿车和卡车。每种车辆有车辆编号、车牌号、车辆制造公司、车辆购买时间、车辆型号(大客车、小轿车和卡车)、总公里数、耗油量/公里、基本维护费用、养路费、累计总费用等信息。大客车还有载客量信息,小轿车还

2、有厢数信息,卡车还有载重量信息。每台车辆当月总费用=油价*耗油量/公里+基本维护费用。基本维护费用:客车:2000元/月;小轿车:1000元/月;卡车:1500元/月功能要求:A.添加车辆B.查询车辆C.显示车辆信息库D.修改车辆E.删除车辆 F.统计功能G.保存车辆H.读取车辆二、总体设计(1)定义基类base,设计出函数框架;(2)派生car类、truck类、bus类,在其中具体实现函数功能;(3)分别设计轿车、卡车、客车管理子菜单,主函数中设计添加总菜单,解决问题。模块图1:base publiccartruckbus read()show()add()modify(int)del(in

3、t)save()car_manage()truck_manage ()bus_manage()search()search_number()main模块图2:类图:base+count_mun:int=0+base():void+base():void+read()+add()+modify():int+del():int+save()+show()+js() cartruckbus+a:string+a:string+a:string+b:string+b:string+b:string+c:string+c:string+c:string+d:string+d:string+d:strin

4、g+e:string+e:string+e:string+f:double+f:double+f:double+g:double+g:double+g:double+h:double+h:double+h:double+i:double+i:double+i:double+zfy:double+zfy:double+zfy:double+l:int+l:int+j:int+count_carmun:int+count_truckmun:int+count_busmun:int+car()+truck()+bus()+car()+truck()+bus()+car(string, string,

5、 string,string,string,double,double,double, double, int)+truck(string, string, string, string, string, double, double, double, double, int)+bus(string, string, string, string, string, double, double, double, double, int)+read():void+read():void+read():void+add():void+add():void+add():void+modify():i

6、nt+modify():int+modify():int+del():int+del():int+del():int+save():void+save():void+save():void+show():void+show():void+show():void+js():void+js():void+js():void三、详细设计(以car类为例)car.cpp:1.构造函数car():功能:用于定义一个空的对象方便操作。2.重载构造函数car(string,string,string,string,string,double,double,double, double, int):参数:st

7、ring编号,string车牌号,string制造公司,string购买时间,string型号,double总公里数,double油价,double耗油量/公里,double养路费,int厢数。功能:用于初始化对象,在文件中直接提取数据形成对象。3.析构函数car():功能:释放对象内存。4.read()函数:功能:从预设的文本文件中提取数据,初始化成car类对象并一一存入vector容器中。5.add()函数:功能:通过新建car对象存入vector容器中,便于在后续操作中写入文件。6.modify()函数:参数:int index。功能:通过index确定要操作的vector数据位置,进行

8、修改。7.del()函数:参数:int index。功能:通过index确定要操作的vector数据位置,进行删除。8.save()函数:功能:打开文本文件进行写入,完成后关闭文件。9.show()函数:功能:输出vector容器中的所有对象。10.js()函数:功能:计算车辆的当月总费用(车辆总费用=油价*耗油量/公里+基本维护费用)车辆信息管理系统.cpp1.main()函数功能:输出总菜单。2.car_manage()函数功能:输出轿车管理子菜单。3.truck_manage()函数功能:输出卡车管理子菜单。4.bus_manage()函数功能:输出客车管理子菜单。5.search()函

9、数功能:输出车辆查询子菜单。6.search_number()函数功能:输出预先统计的各类车辆总数。四、测试与调试调试成功,各功能均可实现。1)在调试过程中遇到的问题:1.将数据写入文件。在设计文件的输入输出时遇到了较大的阻力,不明白怎么将输入到内存里的数据怎么再输入到文件里,而且还可以继续用。2.添加和修改菜单的报错问题。总是无法完美的实现输入错误编号时的错误提醒输出。3.文件的再读取。运行完一遍程序后再运行就报错。2)解决办法:1.查看老师的程序,同时借鉴别人输入输出的方法,完美的解决了自己的问题。2.通过对bool值的死循环套用,令函数在bool为真时才能跳出,bool为假时可以提醒使用

10、者输入正确的编号,解决了这一问题,实现了良好的输出。3.改save()函数中的分隔符” ”为”t”后解决问题。五、源程序清单和执行结果A.车辆信息管理系统.cpp:#include stdafx.h#include #include #include base.h#include car.h#include truck.h#include bus.h#includeiostreamusing namespace std;int base:count_num = 0;int car:count_carnum = 0;int truck:count_trucknum = 0;int bus:cou

11、nt_busnum = 0;vector vec_car;vectorvec_truck;vectorvec_bus;/字符串分割函数vector split(string str, string pattern) string:size_type pos; vector result; str += pattern;/扩展字符串以方便操作 unsigned int size = str.size(); for (unsigned int i = 0; isize; i+) pos = str.find(pattern, i); if (possize) string s = str.subs

12、tr(i, pos - i); result.push_back(s); i = pos + pattern.size() - 1; return result;base *p = NULL;char out;/轿车管理子菜单void car_manage() system(title 轿车管理子菜单);/设置窗口标题 system(color 3F);/设置子菜单背景色:湖蓝色,字体颜色:亮白色 int choice, i = 0; bool quit = false; while (1) system(cls); cout *轿车管理子菜单* endl; cout 1.查看车辆信息 end

13、l; cout 2.添加车辆信息 endl; cout 3.修改车辆信息 endl; cout 4.删除车辆信息 endl; cout 5.统计车辆数 endl; cout 0.退出 endl; cout * endl; cout choice; switch (choice) case 1: car c1; p = &c1; cout n编号 车牌号 制造商 购买时间 型号 公里数 油价 耗油量 养路费 厢数 总费用 show(); system(pause); break; case 2: string a, b, c, d, e, j; double f, g, h, i;int l;

14、cout n编号 车牌号 制造商 购买时间 型号 公里数 油价 耗油量 养路费 厢数 总费用 endl; vector :iterator it; for (it = vec_car.begin();it != vec_car.end();+it) cout a b c d e f g h i l zfy endl; while (1) cout a b c d e f g h i l; car c2(a, b, c, d, e, f, g, h, i, l); p = &c2; bool flag = true; for (it = vec_car.begin();it != vec_car

15、.end();+it) if (!it-pare(a) cout n此车辆的编号已存在,需重新输入! endl; flag = false; break; if (flag) cout j; if (j = y) p-add(); p-save(); if (j = y) break; system(pause); break; case 3: car c3; p = &c3; int index = 0, l; double f, g, h, k; string b, c, d, e, j; cout n编号 车牌号 制造商 购买时间 型号 公里数 油价 耗油量 养路费 厢数 总费用 end

16、l; vector :iterator it; for (it = vec_car.begin();it != vec_car.end();+it) cout a b c d e f g h i l zfy endl; cout c3.a; unsigned int iq = 0; for (bool flag = false;!flag;) for (it = vec_car.begin();it != vec_car.end();+it) iq+; if (!it-pare(c3.a) index = iq; flag = true; break; if (it-pare(c3.a)&iq

17、 = vec_car.size() cout 您输入的编号不存在,请重新操作!n;iq = 0; system(pause);break; if (flag) cout b c d e f g h k l; car c(c3.a, b, c, d, e, f, g, h, k, l); p = &c; cout j; if (j = y) p-modify(index); p-save(); system(pause); else system(pause);break; break; break; case 4: car c4; p = &c4; int index = 0; string

18、id; cout n编号 车牌号 制造商 购买时间 型号 公里数 油价 耗油量 养路费 厢数 总费用 endl; vector :iterator it; for (it = vec_car.begin();it != vec_car.end();+it) cout a b c d e f g h i l zfy endl; cout id; unsigned int i = 0; for (bool flag = false;!flag;) for (it = vec_car.begin();it != vec_car.end();+it) i+; if (!it-pare(id) flag

19、 = true; index = i; if (it-pare(id) & i = vec_car.size() cout 您输入的编号不存在,请重新操作!n; system(pause);i = 0;break; if (flag) cout out; if (out = y) p-del(index); p-save(); system(pause); else system(pause);break; break; break; case 5: cout n所有车辆总数为: base:count_num 其中: endl; cout 轿车总数为: car:count_carnum n e

20、ndl; system(pause); break; case 0:quit = true;system(color 8F);break; default:cout n请输入05之间的数字!n endl;system(pause);break; if (quit = true) break; system(cls); return;/卡车管理子菜单void truck_manage() system(title 卡车管理子菜单);/设置窗口标题 system(color 3F);/设置子菜单背景色:湖蓝色,字体颜色:亮白色 int choice, i = 0; bool quit = fals

21、e; while (1) system(cls); cout *卡车管理子菜单* endl; cout 1.查看车辆信息 endl; cout 2.添加车辆信息 endl; cout 3.修改车辆信息 endl; cout 4.删除车辆信息 endl; cout 5.统计车辆数 endl; cout 0.退出 endl; cout * endl; cout choice; switch (choice) case 1: truck c1; p = &c1; cout n编号 车牌号 制造商 购买时间 型号 公里数 油价 耗油量 养路费 载重量 总费用 show(); system(pause); break; case 2: string a, b, c, d, e, j; double f, g, h, i;int l; cout n编号 车牌号 制造商 购买时间 型号 公里数 油价 耗油量 养路费 载重量 总费用 endl; vector :iterator it; for (it = vec_truck.begin();it != vec_truck.end();+it)

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1