已阅读5页,还剩12页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
西 南 交 通 大 学 课程设计 年级: 大一 学号: 20122734 姓名: 颜俊超 专业: 物联网 指导老师:喻琇瑛 二零一三年六月 一 设计要求 实现一个简单的儿童商品仓库管理系统。系统的主要功能是登记仓库中各儿童用品的信息情况,对部分信息进行检查和处理,并将结果保存。假设仓库有3中不同类型的商品:食品、鞋子、玩具。对于食品,要求检查是否过期,并作相应处理。对于鞋子,要求检查是否过季,如果是就要做出相应处理。把每一类商品当作一个对象,定义一个类,共定义三个类。定义一个基类,儿童商品类,在此基础上派生出三个类。对于每类商品至少要有名称、编号、进价、库存、入库时间、数量等信息。对于每类商品至少包含的功能至少要有信息录入、信息显示等。每类商品的其他信息和功能由同学自己增加。 二 设 计 说 明 1. 题目分析 题目要求总共有四个类,其中儿童商品作为基类派生出食品类、鞋类、玩具类。而三种商品都具有的信息,如商品名称,商品单价,商品生产日期,商品库存数量等四项信息放在基类里进行派生。而像食品类的保质期,鞋类的销售季节期则作为各自的数据成员。2. 类的定义和函数的定义 2.1基类的定义 class child_goods:public Time0public:char name10,stock10,count10,number10;float price; /定义基类的数据void setname(char *sname) strcpy(name,sname);void setnumber(char *snum) strcpy(number,snum);void setprice(float sprice) price=sprice;void setstock(char *sto) strcpy(stock,sto);void setcount(char *sco) strcpy(count,sco); /信息录入void showdata() coutname number ; coutprice stock ; cout入库时间:year0年month0; cout月day0日 countendl;void showname()coutnameendl;void shownumber() cout编号:numberendl;void showprice() cout价格:priceendl;void showstock() cout库存:stockendl;void showcount() cout总数量:countendl; /显示信息; 2.2 食品商品类的定义class food:public child_goods,public Time1public: int baozhiqi;void setbaozhiqi(int bao)baozhiqi=bao; /保质期的设定void showbao()cout保质期是:baozhiqi月=baozhiqi) cout已过期!endl; else cout在保质期内!temp; if(strcmp(season,temp)!=0) cout已过季!endl; else coutseasonendl; /判断是否过季; 2.4 玩具类的定义class toy:public child_goods,public Time1public:int age;void setage(int sage) age=sage;void showage()cout适合年龄:ageendl; /判断是否适合这个年龄阶段; 2.5 几个菜单函数的定义void menu() cout *1 儿童鞋信息录入*endl; cout *2 食品信息录入*endl; cout *3 玩具信息录入*endl; cout *4 儿童鞋信息* endl; cout *5 食品信息* endl; cout *6 玩具信息* endl; cout *其他 返回*endl;void menu1() cout *1 入库时间*endl; cout *2 编号*endl; cout *3 库存*endl; cout *4 价格* endl; cout *5 总数量* endl; cout *6 季节* endl; cout *7 判断是否过季* endl; cout *其他 返回*endl;void menu2() cout *1 入库时间*endl; cout *2 编号*endl; cout *3 库存*endl; cout *4 价格* endl; cout *5 总数量* endl; cout *6 过期判断* endl;cout *7 保质期*endl;cout *8 生产日期*endl; cout *其他 返回*endl;void menu3() cout *1 入库时间*endl; cout *2 编号*endl; cout *3 库存*endl; cout *4 价格* endl; cout *5 总数量* endl; cout *6 适合年龄* endl;cout *7 生产日期*endl; cout *其他 返回*endl;2.6 几个时间基类的定义class Time0public:int year0,month0,day0;void settime0(int y,int m,int d)year0=y;month0=m;day0=d;void showtime() cout入库时间:year0年month0月day0日endl;class Time1public:int year1,month1,day1;void settime(int y,int m,int d)year1=y;month1=m;day1=d;void showtime1() cout生产日期:year1年month1月day1日endl;三 调试结果主菜单如下选择1进入儿童鞋信息录入界面输入信息如上提示输入1继续录入信息输入0返回主界面再按提示输入4进入信息查询按照菜单提示可以键入数字选择查找内容判断鞋是否过季并处理对于食品类判断是否过期并进行处理四 分析和优化 优点:操作界面简洁,提示非常清楚。 缺点:主函数中写的东西过多,应该模块化使得程序更加简洁。 优化:使用文件,使得关机之后数据存档在文件中,下次开机还能够读取数据。使用模块化编写程序,使得主函数清晰明了。五 附件代码:#include#includeusing namespace std;class Time0public:int year0,month0,day0;void settime0(int y,int m,int d)year0=y;month0=m;day0=d;void showtime() cout入库时间:year0年month0月day0日endl;class Time1public:int year1,month1,day1;void settime(int y,int m,int d)year1=y;month1=m;day1=d;void showtime1() cout生产日期:year1年month1月day1日endl;/几个时间类的定义class child_goods:public Time0public:char name10,stock10,count10,number10;float price;void setname(char *sname) strcpy(name,sname);void setnumber(char *snum) strcpy(number,snum);void setprice(float sprice) price=sprice;void setstock(char *sto) strcpy(stock,sto);void setcount(char *sco) strcpy(count,sco); /信息录入void showdata() coutname number ; coutprice stock ; cout入库时间:year0年month0; cout月day0日 countendl;void showname()coutnameendl;void shownumber() cout编号:numberendl;void showprice() cout价格:priceendl;void showstock() cout库存:stockendl;void showcount() cout总数量:countendl;/显示信息;class food:public child_goods,public Time1public: int baozhiqi;void setbaozhiqi(int bao)baozhiqi=bao;void showbao()cout保质期是:baozhiqi月=baozhiqi) cout已过期!endl; else cout在保质期内!endl;/判断是否过期 ;class shoes:public child_goodspublic: char season6; void setseason(char *ssea) strcpy(season,ssea); void judge(char *temp) if(strcmp(season,temp)!=0) cout已过季!endl; else cout没有过季!endl; ;class toy:public child_goods,public Time1public:int age;void setage(int sage) age=sage;void showage()cout适合年龄:ageendl;void menu() cout *1 儿童鞋信息录入*endl; cout *2 食品信息录入*endl; cout *3 玩具信息录入*endl; cout *4 儿童鞋信息* endl; cout *5 食品信息* endl; cout *6 玩具信息* endl; cout *其他 返回*endl;void menu1() cout *1 入库时间*endl; cout *2 编号*endl; cout *3 库存*endl; cout *4 价格* endl; cout *5 总数量* endl; cout *6 季节* endl; cout *7 判断是否过季* endl; cout *其他 返回*endl;void menu2() cout *1 入库时间*endl; cout *2 编号*endl; cout *3 库存*endl; cout *4 价格* endl; cout *5 总数量* endl; cout *6 过期判断* endl;cout *7 保质期*endl;cout *8 生产日期*endl; cout *其他 返回*endl;void menu3() cout *1 入库时间*endl; cout *2 编号*endl; cout *3 库存*endl; cout *4 价格* endl; cout *5 总数量* endl; cout *6 适合年龄* endl;cout *7 生产日期*endl; cout *其他 返回*choice)choice1=1;switch(choice) case 1: cout*儿童鞋信息录入*endl; loop1: coutsname;coutendl; cout入库时间:;coutsi.year0; coutsi.month0; coutsi.day0;coutendl; coutsnumber; coutendl; coutsprice;coutendl; coutsstock;coutendl; coutscount;coutendl; coutsseason;coutendl; si.setname(sname);si.setnumber(snumber); si.setprice(sprice);si.setstock(sstock); si.setcount(scount);si.setseason(sseason); cout*请输入0返回endl*输入1继续录入信息choice1;if(choice1=0) goto loop;else i+;goto loop1;case 2:cout*食品信息录入*endl; loop2: coutsname;coutendl; cout入库时间:;coutfk.year0; coutfk.month0; coutfk.day0;coutendl; cout生产日期:;coutfk.year1; coutfk.month1; coutfk.day1;coutendl; coutsnumber; coutendl; coutsprice;coutendl; coutsstock;coutendl; coutscount;coutendl; coutbao;coutendl; fk.setname(sname);fk.setnumber(snumber); fk.setprice(sprice); fk.setstock(sstock); fk.setcount(scount);fk.setbaozhiqi(bao); cout*请输入0返回endl*输入1继续录入信息choice1;if(choice1=0) goto loop;else k+;goto loop2;case 3: cout*玩具信息录入*endl; loop3: coutsname;coutendl; cout入库时间:;couttm.year0; couttm.month0; couttm.day0;coutendl; cout生产日期:;couttm.year1; couttm.month1; couttm.day1;coutendl; coutsnumber;coutendl; coutsprice;coutendl; coutsstock;coutendl; coutscount;coutendl; coutsage;coutendl; tm.setname(sname);tm.setnumber(snumber); tm.setprice(sprice);tm.setstock(sstock); tm.setcount(scount);tm.setage(sage); cout*请输入0返回endl*输入1继续录入信息choice1;if(choice1=0) goto loop;else m+;goto loop3;case 4: coutfind; for(j=0;jchoice1;switch (choice1)case 1:sj.showtime();goto loop4;case 2:sj.shownumber();goto loop4;case 3:sj.showstock();goto loop4;case 4:sj.showprice();goto loop4;case 5:sj.showcount();goto loop4;case 6:coutsj.season季节endl;goto loop4;case 7:coutt
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 经营管理部部门职责
- DB5306T 109-2023 金佛山方竹低产林改造技术规程
- 2026湖州市农业农村局所属事业单位高层次人才招聘2人备考题库带答案详解
- 纺织印染工序安全制度
- 2026南方科技大学附属中学招聘14人备考题库及答案详解一套
- 川南幼儿师范高等专科学校2026年普通高校助学助管员招聘备考题库(39人)及1套参考答案详解
- 2026北京大学新校区管理委员会办公室招聘劳动合同制工作人员1名备考题库完整参考答案详解
- 2026石化智能运维工程师岗位招聘备考题库含答案详解
- 2026福建省农业融资担保有限公司招聘3人备考题库及答案详解一套
- 2026江苏南京市鼓楼区机关事业单位招聘2人备考题库(挹江门街道安全员)及参考答案详解
- 《土木工程智能施工》课件 第4章 基础工程-浅基础工程
- 2024-2025学年陕西省渭南市蒲城县七年级(下)期末历史试卷(含答案)
- 2025年国家能源投资集团有限责任公司校园招聘笔试备考题库含答案详解(新)
- 中华护理学会学术会汇报
- 医疗结构化面试经典100题及答案
- 七一党课:传承红色基因勇担时代使命2025年建党104周年“七一”专题党课
- 带量采购培训课件
- 初三化学最后一课-主题班会【课件】
- 环境噪声技师试题及答案
- 广东省深圳市2025年七年级下学期期末数学模拟试题五套附答案
- QC岗前培训内容
评论
0/150
提交评论