1、C+课程设计商品销售管理系统C+课设 商品销售管理系统 一、需求分析.2二、概要设计.2三、详细设计.3四、调试分析.9五、用户手册.10六、测试数据.11七、附录.12 1一、需求分析 商品销售管理程序 商品信息:商品编号、商品名称、商品类别(普通电视机、DVD、带DVD的电视机,带DVD的电视机的售价为普通电视机和DVD单价之和的80%)、商品进货价格、商品销售价格、商品数量、供应商名称等。 记录每一次销售商品的数量和价格,并提供对已售出商品的价格、数量进行统计、排序功能,但允许用户退商品。(要求:1.源文件采用多文件的工程结构2.数据存储采用文件形式3.标准的C输入输出4.功能完善,适当
2、的注释,5.关于文件的内容需要自学)二、概要设计1、数据类(class Data)的数据类型定义:class Data /数据类private: int id; /产品编号 char name100; /产品名称 int count; /库存数量 int salecount; /已售数量 float iprice; /进价 float oprice ; /售价 char gys20; /供应商Public: /公有函数 int getid() /获取id char *getname() /获取产品名 Int getcount() /获取库存量 Int getsalecount() /获取已售量
3、 Float getbuy() /获取进价 Float getsale() /获取售价 Char *getgys() /获取供应商 2 Void setid(int n) /输入id Void setname(char na) /产品名 Void setcount(int c) /库存量 Void setsalecount(int s) /已售量 Void setbuy(float i) /进价 Void setsale(float o) /售价 Void setgys(char g) /供应商;2、class commodity 商品类设计:class Commodity /商品类priva
4、te: Data t50; /数组 2 int n; /商品数量public: void newFile() /添加商品信息 void showData(int i) /显示商品信息 void showData() /显示文字信息 void save() /写入数据至文件 int search() /商品查询 void sale() /商品销售结算 void showSale() /销售清单 inline void menu() /主菜单 3、本程序结构 (1)主函数 Void main() menu(); Commodity com; int c; switch(c)return Break
5、;(2)数据类实现对数据的输入输出。(3)商品类系统各项功能的实现。三、详细设计 (1)数据类 class Data /数据类private: int id;/产品编号 char name100;/产品名称 int count;/库存数量 int salecount;/已售数量 float iprice;/进价 float oprice;/售价 char gys20;/供应商public: int getId() return id; char *getName() return name; int getCount() 3 return count; int getSaleCount() r
6、eturn salecount; 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 setSaleCount(int s) salecount=s; void setBuy(float i) iprice=i; void setSale(float o) oprice=o
7、; 4 /. void setGys(char g) strcpy(gys,g); ;(2)商品类 class Commodity /商品类 private: Data t50; /数组 int n; /商品数量 public: void newFile() int id; char name50; /字符数组 int count; float iprice; float oprice; char gys20; if(n0) n=0; int i; Data temp; for(;n+) coutid; if(id=-1) break; tn.setId(id); coutname; tn.s
8、etName(name); coutcount; tn.setCount(count); coutiprice; tn.setBuy(iprice); coutoprice; tn.setSale(oprice); coutgys; tn.setGys(gys); tn.setSaleCount(0);/售出此产品0个 cout若商品添加完毕,请按-1退出添加!endl; for(i=0;itn.getId() temp=ti; ti=tn; tn=temp; void showData(int i) coutti.getId() setw(10)ti.getName() setw(10)ti
9、.getCount() setw(10)ti.getSaleCount() 6 setw(8)ti.getBuy() setw(8)ti.getSale() setw(8)ti.getGys()endl; void showData() cout商品编号 setw(8)商品名 setw(8)库存量 setw(10)已售量 setw(10)进价 setw(8)售价 6 setw(8)供应商endl; for(int i=0;i0 ) showData(i); cout产品种类:nendl; void save() /写入数据至文件 ofstream fout; fout.open(商品销售管理系
10、统.txt); 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()setw(10)ti.getSaleCount(); cout*Save Success!*endl; fout.close(); int sear
11、ch() int id; coutid; int low=0,mid,high=n-1; while(lowid) high=mid-1; Else low=mid+1; 7 return -1; void sale() cout产品编号; int temp; temp=search(); if(temp=-1) coutcannot find the commodity!endl; return; if(ttemp.getCount()=0) cout此产品已缺!endl; int count; coutcount; float money; coutmoney; if(countttemp
12、.getCount()/输入的是负数或超出该产品库存量 cout数量输入不正确endl; else if(moneyttemp.getSale()*count) 8 cout购物金额不足,还需增加金额ttemp.getSale()*count-money元endl; else ttemp.setCount(ttemp.getCount()-count);/当前库存减少count ttemp.setSaleCount(ttemp.getSaleCount()+count);/出售量增加count cout*名称:ttemp.getName()endl *数量:countendl *单价:ttem
13、p.getSale()元endl 8 *应收:count*ttemp.getSale()元endl *找零:money-count*ttemp.getSale()元endl *endl; void showSale() for(int i=0;i0 ) showData(i); ;(3)主函数inline void menu() cout *欢迎使用商品销售管理系统* endl; cout *主菜单* endl; cout (1)添加 endl; cout (2)保存 endl; cout (3)显示 endl; cout (4)菜单 endl; cout (5)销售单 endl; cout
14、(0)退出系统 endl; cout *2011-2012* endl; void main() menu(); Commodity com; int c; for(;) coutc; 9 switch(c) case 1:com.newFile();break; case 2:com.save();break; case 3:com.showData();break; case 4:menu();break; case 5:com.sale();break; case 0: cout *谢谢使用* endl; cout *!再见!* endl; return; break; 四、调试手册(1
15、)、error C2143: syntax error : missing ; before 行246少了一个分号(2)、error C2562: main : void function returning a value空类型不能有返回值(3)、error C2679: binary : no operator defined which takes a right-hand operand of type (or there is no acceptable conversion) ti.getName后面少了()五、用户手册1、本程序的运行环境为windows操作系统,执行文件为Ks.
16、exe;2、进入演示程序后,即显示对话形式的提示操作过程:如:第一项:(1)商品添加功能在选择一栏输入:1即显示商品编号、商品名、库存量、进价、售价、供应商各项商 品信息,依次输入所需添加的数据 。添加商品完毕,按-1退出添加。选择:2 即将商品信息保存。选择:3 显示已保存的商品信息。选择:4 重新回到主菜单。选择:5 进行商品销售结算。同时选择:3 显示商品库存和已销售的完整信息。六、测试数据 进入演示程序后,即显示对话形式的提示操作过程:选择:1 10输入相应提示的商品信息选择:2 界面显示数据保存成功选择:3 显示商品信息 11选择:4 重新回到主菜单选择:5 进行商品结算选择:3 显
17、示商品信息七、附录程序源代码:#include#include#include#include /为了声明标识符setw()函数#define Mfname 100class Data /数据类private: int id;/产品编号 char name100;/产品名称 int count;/库存数量 int salecount;/已售数量 float iprice;/进价 float oprice;/售价 char gys20;/供应商public: int getId() return id; char *getName() return name; int getCount() re
18、turn count; int getSaleCount() return salecount; float getBuy() return iprice; 12 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 setSaleCount(int s) salecount=s; void setBuy(float i) ipric
19、e=i; void setSale(float o) oprice=o; /. void setGys(char g) strcpy(gys,g); ;class Commodity /商品类private: 13 Data t50; /数组 int n; /商品数量public: void newFile() int id; char name50; /字符数组 int count; float iprice; float oprice; char gys20; if(n0) n=0; int i; Data temp; for(;n+) coutid; if(id=-1) break; t
20、n.setId(id); coutname; tn.setName(name); coutcount; tn.setCount(count); coutiprice; tn.setBuy(iprice); coutoprice; tn.setSale(oprice); coutgys; tn.setGys(gys); tn.setSaleCount(0);/售出此产品0个 14 cout若商品添加完毕,请按-1退出添加!endl; for(i=0;itn.getId() temp=ti; ti=tn; tn=temp; void showData(int i) 15 coutti.getId(
21、) setw(10)ti.getName() setw(10)ti.getCount() setw(10)ti.getSaleCount() setw(8)ti.getBuy() setw(8)ti.getSale() setw(8)ti.getGys()endl; void showData() 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); if(!fout) 15coutcannot open the file!endl; return ; fout商品编号 商品名 库存量 进价 售价 供应商 已售量endl; for(int i=0;in;i+) foutti.getId()setw(14)ti.getName()setw(10)ti
copyright@ 2008-2022 冰豆网网站版权所有
经营许可证编号:鄂ICP备2022015515号-1