C++课程设计-商品管理系统_第1页
C++课程设计-商品管理系统_第2页
C++课程设计-商品管理系统_第3页
C++课程设计-商品管理系统_第4页
C++课程设计-商品管理系统_第5页
已阅读5页,还剩34页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

1、.淮 海 工 学 院 计 算 机 工 程 学 院课程设计报告设计名称: C+程序设计课程设计 姓 名: 学 号: 专业班级: 系 院: 设计时间: 设计地点: 成绩:指导教师评语: 签名: 年 月 日学习文档 仅供参考1、课程设计目的 C+程序设计课程设计是电脑科学与技术专业重要的实践性教学环节之一,本次设计结合实际应用的要求,使课程设计既覆盖C+的知识点,又接近工程实际需要。目的是通过课程设计的综合训练,培养学生实际分析问题、解决问题的能力,以及编程和动手能力,最终目标是通过课程设计这种形式,帮助学生系统掌握C+程序设计这门课程的主要内容,养成良好的编程习惯,更好的完成教学任务。2、课程设计

2、任务与要求:本次课程设计利用C+程序设计课程中所学到的编程知识和编程技巧,完成具有一定难度和工作量的程序设计题目,帮助学生掌握编程、调试的基本技能,独立完成所布置的任务。要求:1、对系统进行功能需求分析2、设计合理的数据结构和系统框架3、编程简练,程序功能齐全,能正确运行4、说明书、流程图要清楚5、课题完成后必须按要求提交课程设计报告任务:设计一个商品销售管理系统。运用C+语言描述商品类、供给商类。要求设计中综合运用C+基础知识,利用指针对商品、供给商链表进行处理,方便快捷的进行增删改,充分利用友元来处理两个类之间的关系,理解面向对象程序设计的核心的概念。实现功能:1建立商品类、供给商类2商品

3、、供给商信息的初始化3商品信息的添加、修改、删除、 查找4供给商信息的添加、修改、删除、查找5商品信息、供给商信息的输出备注:将商品、供给商保存为文件,能够写入与读出。概要设计(1) 需求分析:要实现对商品,供给商信息的添加、修改、删除、查找,并输出信息,能够方便快捷,并有用户能详细清楚的操作指南。2模块说明:本次程序设计中,需要设计10个模块,分别是添加、修改、删除、查找、输出商品信息和供给商信息,一共4个类:分别是商品类、商品数据类、供给商类、供给商数据类。通过几个switch语句实现用户选择功能。主要函数流程图:3详细设计 商品数据类的设计class spData private: ch

4、ar name100;int count;float iprice;float oprice; char gys20;public: int id;int getId()char *getName()int getCount()float getBuy() float getSale()char *getGys()void setId(int n)void setName(char na)void setCount(int c)void setBuy(float i)void setSale(float o) void setGys(char g);商品类的设计class Commodity

5、private:spData t50; int n;public:void newFile()int id;int n;char name50; int count;float iprice;float oprice; char gys20;if(n0) n=0; int i;spData temp; for(;n+)coutid;if(id=-1)break;tn.setId(id);coutname;tn.setName(name);coutcount;tn.setCount(count);coutiprice;tn.setBuy(iprice);coutoprice;tn.setSale

6、(oprice);coutgys;tn.setGys(gys); cout假设商品添加完毕,请按-1退出添加!endl;for(i=0;itn.getId()temp=ti;ti=tn;tn=temp;void showData(int i)spData t,*p;p=&t;coutgetId()setw(10)getName()setw(10)getCount()setw(8)getBuy()setw(8)getSale()setw(8)getGys()endl;void showData() int n;cout商品编号setw(8)商品名setw(8)库存量setw(10)已售量setw

7、(10)进价setw(8)售价setw(8)供给商endl;for(int i=0;i0 )showData(i);cout商品种类:nendl;void save() ofstream fout;fout.open(商品清单.txt,ios:app); if(!fout)coutcannot open the file!endl;return ;fout商品编号 商品名 库存量 进价 售价 供给商 endl;for(int i=0;in;i+) foutti.getId()setw(14)ti.getName()setw(10)ti.getCount()setw(10)ti.getBuy()

8、setw(10)ti.getSale()setw(10)ti.getGys()endl;cout*Save Success!*endl;fout.close(); void xiugai() int count; char name100;float iprice;float oprice; char gys20;int temp;temp=search();if(temp=-1)coutcannot find the shopping!endl;return;else cout请输入新数据:endl;coutname;ttemp.setName(name);coutcount;ttemp.s

9、etCount(count);coutiprice;ttemp.setBuy(iprice);coutoprice;ttemp.setSale(oprice);coutgys;ttemp.setGys(gys);int search() int id;coutid;int low=0,mid,high=n-1;while(lowid)high=mid-1;else low=mid+1;return -1; void remove() spData t10; cout请输入要删除的商品编号id; fstream file(商品清单.txt,ios:in|ios:out|ios:binary);f

10、or(int u=0;u5;u+)file.read(char*)&tu,sizeof(tu);for(int v=0;v5;v+) if(tv.id=id)continue;elsefile.write(char*)&tv,sizeof(tv);cout该商品被删除endl;file.close();供给商数据类的设计class spData private: char name100;int count;float iprice;float oprice; char gys20;public: int id;int getId()char *getName(char na)int getC

11、ount()float getBuy() float getSale()char *getGys()void setId(int n)void setName(char na)void setCount(int c)void setBuy(float i)void setSale(float o) void setGys(char g);供给商类的设计class gongyingshang private:gysData t50; int n; public:void newFile() int id;char name50;int phone;if(n0) n=0; for(;n+) cou

12、tid;if(id=-1)break;tn.setid();cout供给商名称:;tn.setname(name);cout供给商 :;tn.setphone( ); cout假设供给商添加完毕,请按-1退出添加!endl;void showData(int i)gysData t,*p;p=&t;coutsetw(8)getid()setw(10)getname()setw(10)getphone()endl;void showData()coutsetw(8)供给商编号setw(8)供给商名称setw(8)供给商 endl;for(int i=0;in;i+)showData(i);cou

13、t产品种类:nendl;void save()ofstream fout;fout.open(供给商.txt,ios:app); if(!fout)coutcannot open the file!endl;return ;fout供给商编号 供给商 供给商 号 endl;for(int i=0;in;i+) foutti.getid()setw(10)ti.getname()setw(14)ti.getphone()endl;cout*Save Success!*endl;fout.close(); int search() int id;coutid;int low=0,mid,high=

14、n-1;while(lowid)high=mid-1;else low=mid+1;return -1; void xiugai() char name100; int phone;int temp;temp=search();if(temp=-1)coutcannot find the gys!endl;return;else cout请输入新数据:endl;coutname;ttemp.setname(name);coutphone;ttemp.setphone(); void remove() gysData g10; cout请输入要删除的供给商编号id; fstream file(g

15、ys.txt,ios:in|ios:out|ios:binary);for(int u=0;u5;u+)file.read(char*)&gu,sizeof(gu);for(int v=0;v5;v+) if(gv.id=id)continue;elsefile.write(char*)&gv,sizeof(gv);cout该供给商被删除endl;file.close();菜单函数的设计inline void menu2()system(cls);cout *欢送使用商品销售管理系统* endl;cout *商品选项* endl;cout (1)添加 endl;cout (2)保存 endl;

16、cout (3)删除 endl;cout (4)查找 endl; cout (5)信息输出 endl; cout (6)修改 endl;cout (7)菜单 endl;cout (0)退出系统 endl;cout *2012.6* endl; inline void menu1()system(cls); cout *欢送使用商品销售管理系统* endl;cout *主菜单* endl;cout (1)商品选项 endl;cout (2)供给商选项 endl;cout (0)退出系统 endl;cout *2012.6* endl; inline void menu3()system(cls)

17、;cout *欢送使用商品销售管理系统* endl;cout *供给商选项* endl;cout (1)添加 endl;cout (2)保存 endl; cout (3)删除 endl;cout (4)查找 endl; cout (5)信息输出 endl; cout (6)修改 endl;cout (7)菜单 endl; cout (0)退出系统 endl;cout *2012.6* endl;主函数的设计:int main()menu1();int x;coutx;switch(x)case 1:menu2();Commodity com;int c;for(;)coutc;switch(c

18、)case 1:com.newFile();break;case 2:com.save();break;case 3:com.remove();break; case 4:com.search;break; case 5:com.showData();break; case 6:menu1();break;case 0:cout *谢谢使用* endl;cout *!再见!* endl; break;case 2:menu3();gongyingshang gys;int c;for(;)coutc;switch(c)case 1:gys.newFile();break;case 2:gys.

19、save();break; case 3:gys.remove();break; case 4:gys.showData();break; case 5:gys.search();break;case 6:menu1();break;case 0:cout *谢谢使用* endl;cout *!再见!* endl; break;case 0:cout *谢谢使用* endl;cout *!再见!* endl; break;return 0;4调试分析:F:程序3.cpp(226) : warning C4700: local variable n used without having bee

20、n initializedF:程序3.cpp(246) : warning C4700: local variable c1 used without having been initializedF:程序3.cpp(348) : warning C4700: local variable g1 used without having been initializedC:Documents and SettingsAdministrator桌面q.cpp(237) : error C2562: search : void function returning a value C:Documen

21、ts and SettingsAdministrator桌面q.cpp(228) : see declaration of searchC:Documents and SettingsAdministrator桌面q.cpp(243) : error C2562: search : void function returning a value C:Documents and SettingsAdministrator桌面q.cpp(228) : see declaration of search(5)用户使用说明手册:1.进入演示程序后,即显示对话形式的提示操作过程: 如第一个选择1 商品选

22、项 ,即显示 1添加 2保存 3删除 4查找 5信息输出6修改 7菜单 0退出系统 选择1,即显示商品编号、商品名、库存量、进价、售价、供给商各项商品信息,一次输入所添加的数据。添加完毕,按-1退出添加;选择2,即将商品信息保存;选择3,删除要删除的商品信息;选择4,查找商品信息;选择5,信息的输出;选择6,修改信息选择7,返回到菜单;选择0,退出系统。如第一个选择2,供给商选项 ,同样显示 1添加 2保存 3删除 4查找 5信息输出6修改 7菜单 0退出系统 选择数据的功能跟上面一样。第一个选择0 退出系统。6测试数据进入演示程序后,即显示对话形式的提示操作过程:选择:1 商品选项选择:1

23、添加商品选择:2 保存信息选择:3 删除信息选择:4 查找信息选择:5 信息输出选择:6 修改选择:0 退出系统选择:2 供给商选项供给商信息的各选项跟商品信息的选项一样。4课程设计成果程序源代码#include#include#include#include #define Mfname 100#include #include #include #includeclass spData private: char name100;int count;float iprice;float oprice; char gys20;public: int id;int getId()return

24、id;char *getName()return name;int getCount()return count;float getBuy()return iprice; float getSale()return oprice;char *getGys()return gys;void setId(int n)id=n;void setName(char na)strcpy(name,na);void setCount(int c)count=c; void setBuy(float i)iprice=i;void setSale(float o)oprice=o; void setGys(

25、char g) strcpy(gys,g);class gysDataprivate:char name100;int phone;public: int id;int getid()return id;char *getname()return name;int getphone()return phone;void setid()cinid;void setname(char na)strcpy(name,na);void setphone()cinphone;class Commodity private:spData t50; int n;public:void newFile()in

26、t id;int n;char name50; int count;float iprice;float oprice; char gys20;if(n0) n=0; int i;spData temp; for(;n+)coutid;if(id=-1)break;tn.setId(id);coutname;tn.setName(name);coutcount;tn.setCount(count);coutiprice;tn.setBuy(iprice);coutoprice;tn.setSale(oprice);coutgys;tn.setGys(gys); cout假设商品添加完毕,请按-

27、1退出添加!endl;for(i=0;itn.getId()temp=ti;ti=tn;tn=temp;void showData(int i)spData t,*p;p=&t;coutgetId()setw(10)getName()setw(10)getCount()setw(8)getBuy()setw(8)getSale()setw(8)getGys()endl;void showData() int n;cout商品编号setw(8)商品名setw(8)库存量setw(10)已售量setw(10)进价setw(8)售价setw(8)供给商endl;for(int i=0;i0 )sho

28、wData(i);cout商品种类:nendl;void save() ofstream fout;fout.open(商品清单.txt,ios:app); if(!fout)coutcannot open the file!endl;return ;fout商品编号 商品名 库存量 进价 售价 供给商 endl;for(int i=0;in;i+) foutti.getId()setw(14)ti.getName()setw(10)ti.getCount()setw(10)ti.getBuy()setw(10)ti.getSale()setw(10)ti.getGys()endl;cout*

29、Save Success!*endl;fout.close(); void xiugai() int count; char name100;float iprice;float oprice; char gys20;int temp;temp=search();if(temp=-1)coutcannot find the shopping!endl;return;else cout请输入新数据:endl;coutname;ttemp.setName(name);coutcount;ttemp.setCount(count);coutiprice;ttemp.setBuy(iprice);co

30、utoprice;ttemp.setSale(oprice);coutgys;ttemp.setGys(gys);int search() int id;coutid;int low=0,mid,high=n-1;while(lowid)high=mid-1;else low=mid+1;return -1; void remove() spData t10; cout请输入要删除的商品编号id; fstream file(商品清单.txt,ios:in|ios:out|ios:binary);for(int u=0;u5;u+)file.read(char*)&tu,sizeof(tu);f

31、or(int v=0;v5;v+) if(tv.id=id)continue;elsefile.write(char*)&tv,sizeof(tv);cout该商品被删除endl;file.close();class gongyingshang private:gysData t50; int n; public:void newFile() int id;char name50;int phone;if(n0) n=0; for(;n+) coutid;if(id=-1)break;tn.setid();cout供给商名称:;tn.setname(name);cout供给商 :;tn.setphone( ); cout假设供给商添加完毕,请按-1退出添加!endl;void showData(int i)gysData t,*p;p=&t;coutsetw(8)getid()setw(10)getname()setw(10)getphone()endl;void showData()coutsetw(8)供给商编号setw(8)供给商名称setw(8)供给商 endl;for(int i=0;in;i+)showData(i);cout产品种类:nendl;void save

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论