欢迎来到天天文库
浏览记录
ID:38528604
大小:88.50 KB
页数:18页
时间:2019-06-14
《超市管理系统课程设计源码C++》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、//supermarket.cpp:Definestheentrypointfortheconsoleapplication.////#include"stdafx.h"////intmain(intargc,char*argv[])//{//return0;//}#include#include#include#include#includeintn=0;//全局数据,结点数量classGoods{protec
2、ted:charname[20];//商品名称doublenum;//商品代码charaddress[30];//商品产地intprice;//商品单价doublecount;//该类商品库存量Goods*next;public:Goods(doublenum,char*name,char*address,intprice,doublecount){this->num=num;strcpy(this->name,name);strcpy(this->address,address);this->price=pric
3、e;this->count=count;}voidOutput(){cout<<"num:"<4、permarket(){Goods*p;p=goods;while(p){p=p->next;deletegoods;goods=p;}goods=NULL;}voidAdd();//增加商品voidDelete();//删除商品voidModify();//修改商品voidQuery();//查询商品voidAdd_up();//统计商品voidSave();//基础数据存盘voidLoad();//基础数据装入voidgood_initial(doublenum,doublecount,charname[20]5、,charaddress[30],intprice);//物品初始化};voidSupermarket::Clear()//清除内存中商品数据(内部使用){Goods*p;p=goods;while(p){goods=p->next;deletep;p=goods;}}voidSupermarket::Add(){Goods*p;doublenum,count;charname[20],address[30];intprice;cout<<"请输入新增商品信息:";cout<<"商品代码:";cin>>nu6、m;cout<<"商品名称:";cin>>name;cout<<"商品产地:";cin>>address;cout<<"商品单价:";cin>>price;cout<<"该商品库存量:";cin>>count;//创建新商品类结点p=newGoods(num,name,address,price,count);p->next=NULL;if(goods==NULL){goods=p;n++;}else{Goods*p2=goods;while(p2->next)p2=p2->next;p2->next=p;n++;7、}}voidSupermarket::good_initial(doublenum,doublecount,charname[20],charaddress[30],intprice){Goods*p;//创建新商品类结点p=newGoods(num,name,address,price,count);p->next=NULL;if(goods==NULL){goods=p;n++;}else{Goods*p2=goods;while(p2->next)p2=p2->next;p2->next=p;n++;}}vo8、idSupermarket::Delete()//删除商品{charname[20];cout<<"请输入要删除的商品名称:";cin>>name;//查找要删除的结点Goods*p1,*p2;p1=goods;while(p1){if(strcmp(p1->name,name)==0)break;else{p2=p1;p1=p1->next;}}/
4、permarket(){Goods*p;p=goods;while(p){p=p->next;deletegoods;goods=p;}goods=NULL;}voidAdd();//增加商品voidDelete();//删除商品voidModify();//修改商品voidQuery();//查询商品voidAdd_up();//统计商品voidSave();//基础数据存盘voidLoad();//基础数据装入voidgood_initial(doublenum,doublecount,charname[20]
5、,charaddress[30],intprice);//物品初始化};voidSupermarket::Clear()//清除内存中商品数据(内部使用){Goods*p;p=goods;while(p){goods=p->next;deletep;p=goods;}}voidSupermarket::Add(){Goods*p;doublenum,count;charname[20],address[30];intprice;cout<<"请输入新增商品信息:";cout<<"商品代码:";cin>>nu
6、m;cout<<"商品名称:";cin>>name;cout<<"商品产地:";cin>>address;cout<<"商品单价:";cin>>price;cout<<"该商品库存量:";cin>>count;//创建新商品类结点p=newGoods(num,name,address,price,count);p->next=NULL;if(goods==NULL){goods=p;n++;}else{Goods*p2=goods;while(p2->next)p2=p2->next;p2->next=p;n++;
7、}}voidSupermarket::good_initial(doublenum,doublecount,charname[20],charaddress[30],intprice){Goods*p;//创建新商品类结点p=newGoods(num,name,address,price,count);p->next=NULL;if(goods==NULL){goods=p;n++;}else{Goods*p2=goods;while(p2->next)p2=p2->next;p2->next=p;n++;}}vo
8、idSupermarket::Delete()//删除商品{charname[20];cout<<"请输入要删除的商品名称:";cin>>name;//查找要删除的结点Goods*p1,*p2;p1=goods;while(p1){if(strcmp(p1->name,name)==0)break;else{p2=p1;p1=p1->next;}}/
此文档下载收益归作者所有