1、C+课程设计商品管理系统word文档良心出品.淮 海 工 学 院 计 算 机 工 程 学 院课程设计报告设计名称: C+程序设计课程设计 姓 名: 学 号: 专业班级: 系 (院): 设计时间: 设计地点: 成绩:指导教师评语: 签名: 年 月 日1、课程设计目的 C+程序设计课程设计是计算机科学与技术专业重要的实践性教学环节之一,本次设计结合实际应用的要求,使课程设计既覆盖C+的知识点,又接近工程实际需要。目的是通过课程设计的综合训练,培养学生实际分析问题、解决问题的能力,以及编程和动手能力,最终目标是通过课程设计这种形式,帮助学生系统掌握C+程序设计这门课程的主要内容,养成良好的编程习惯,
2、更好的完成教学任务。2、课程设计任务与要求:本次课程设计利用C+程序设计课程中所学到的编程知识和编程技巧,完成具有一定难度和工作量的程序设计题目,帮助学生掌握编程、调试的基本技能,独立完成所布置的任务。要求:1、对系统进行功能需求分析2、设计合理的数据结构和系统框架3、编程简练,程序功能齐全,能正确运行4、说明书、流程图要清楚5、课题完成后必须按要求提交课程设计报告任务:设计一个商品销售管理系统。运用C+语言描述商品类、供应商类。要求设计中综合运用C+基础知识,利用指针对商品、供应商链表进行处理,方便快捷的进行增删改,充分利用友元来处理两个类之间的关系,理解面向对象程序设计的核心的概念。实现功
3、能:(1)建立商品类、供应商类(2)商品、供应商信息的初始化(3)商品信息的添加、修改、删除、 查找(4)供应商信息的添加、修改、删除、查找(5)商品信息、供应商信息的输出备注:将商品、供应商保存为文件,能够写入与读出。概要设计(1) 需求分析:要实现对商品,供应商信息的添加、修改、删除、查找,并输出信息,能够方便快捷,并有用户能详细清楚的操作指南。(2)模块说明:本次程序设计中,需要设计10个模块,分别是添加、修改、删除、查找、输出商品信息和供应商信息,一共4个类:分别是商品类、商品数据类、供应商类、供应商数据类。通过几个switch语句实现用户选择功能。主要函数流程图:(3)详细设计 商品
4、数据类的设计class spData private: char 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)
5、 void setGys(char g);商品类的设计class Commodity 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.setCou
6、nt(count); coutiprice; tn.setBuy(iprice); coutoprice; tn.setSale(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)
7、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 ) showData(i); cout商品种类:nendl; void save() ofstream fout; fout.open(商品清单.txt,ios:app); if(!fout) coutcannot open the file!endl; return ; fout商品编号 商品名 库存量 进价 售价 供应商 endl
8、; 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*Save Success!*endl; fout.close(); void xiugai() int count; char name100; float iprice; float oprice; char gys20; int temp; temp=search(); if(temp=-1) coutc
9、annot find the shopping!endl; return; else cout请输入新数据:endl; coutname; ttemp.setName(name); coutcount; ttemp.setCount(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;
10、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); for(int v=0;v5;v+) if(tv.id=id) continue; else file.write(char*)&tv,sizeof(tv); cout该商品被删除endl; file.close(); ;供应商数据类的设计class s
11、pData private: char name100; int count; float iprice; float oprice; char gys20;public: int id; int getId() char *getName(char na) 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 gongyingshang private: gysData t50; int n; public: void newFile() int id; char name50; int phone; if(n0) n=0;