版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、关于超市商品管理系统C+程序基本功能:基本功能(供参考)有:1、添加商品信息,有商品编号、商品名、供应商代号、进货价、售出价、存货数等。2、2、进货:若商品已存在,只需修改存货数;若不存在,需增加新纪录。3、售出:输入商品编号,修改相应的存货数与销售额。4、查询:查询商品、销售额# include <iostream># include <fstream># include <string.h>#include <conio.h>/用getch();using namespace std;/commodity类class commoditypub
2、lic: char name20; char Id20; int buy;/进货价; int sale;/卖出价; int amount;/数量; int sum;/利润; commodity * Next; void Input() cout<<"tt请输入商品的名称:" cin>>name; cout<<"tt请输入商品的编号:" cin>>Id; cout<<"tt请输入进货价:" cin>>buy; cout<<"tt请输入售出价:&
3、quot; cin>>sale; cout<<"tt请输入商品数量:" cin>>amount; sum=(sale-buy)*amount; void Read & in) in>>name>>Id>>sale>>buy>>sum; void Show() cout<<"商品名"<<name<<endl<<"编号:"<<Id<<endl<<&quo
4、t;进货价"<<buy<<"售出价"<<sale<<"商品数量:"<< amount<<"预计总利润:"<<sum<<endl<<endl<<endl; ;/Commoditymassage类class Commoditymassagepublic: Commoditymassage(); Commoditymassage(); void ShowMenu(); void Find();void Save(
5、); void ModifyItem(); void RemoveItem(); void S *,commodity *); void Sort(); int ListCount(); void Display() for(commodity * p=Head->Next;p!=End;p=p->Next) p->Show(); cout<<"输入任意字符!继续" getch(); void AddItem() End->Input(); End->Next=new commodity; End=End->Next; cou
6、t<<"添加成功!"<<endl; cout<<"输入任意字符!继续" getch(); private: commodity * Head,* End; ifstream in; ofstream out; commodity *FindItem(char * name) for(commodity * p=Head;p->Next!=End;p=p->Next)/匹配成功则返回上一个指针,不成功就返回空 if(!strcmp(p->Next->name,name)return p; retu
7、rn NULL; commodity *FindID(char * Id) for(commodity * p=Head;p->Next!=End;p=p->Next)/匹配成功则返回上一个指针,不成功就返回空 if(!strcmp(p->Next->Id,Id)return p; return NULL; ;/构造函数Commoditymassage:Commoditymassage() Head=new commodity; Head->Next=new commodity; End=Head->Next; in.open("sort.txt&
8、quot;); if(!in) cout<<"无商品信息。请先输入。"<<endl; else while(!in.eof() End->Read); if(End->name0='0')break; End->Next=new commodity; End=End->Next; in.close(); cout<<"tt读取商品信息成功!"<<endl; /析构函数Commoditymassage:Commoditymassage() Save(); for(com
9、modity * temp;Head->Next!=End;) temp=Head->Next; Head->Next=Head->Next->Next; delete temp; delete Head,End;/菜单void Commoditymassage:ShowMenu() cout<<" 超 市 商 品 管 理 系 统 "<<endl; cout<<" "<<endl; cout<<" 1.增加超市商品 "<<endl;
10、cout<<" 2.显示超市商品 "<<endl; cout<<" 3.排序统计商品 "<<endl; cout<<" 4.查找超市商品 "<<endl; cout<<" 5.删除超市商品 "<<endl; cout<<" 6.修改超市商品 "<<endl; cout<<" 0.安全退出系统 "<<endl; cout<<
11、"nttntt请选择:"/查找函数void Commoditymassage:Find() char name20 ,Id10; int x; commodity * p=NULL; cout<<"ntt*n" cout<<"tt 1.按商品的名称查找ntt 2.按商品编号查找" cout<<"ntt*n请选择:" cin>>x; switch(x) case 1:cout<<"tt请输入要查找的商品的名称:"cin>>na
12、me; if(p=FindItem(name) p->Next->Show(); cout<<"输入任意字符!继续" getch(); else cout<<"tt没有找到该名称的商品!"<<'n'<<endl; cout<<"输入任意字符!继续" getch(); break; case 2: cout<<"tt请输入要查找的商品的编号:"cin>>Id; if(p=FindID(Id) p->N
13、ext->Show(); cout<<"输入任意字符!继续" getch(); else cout<<"tt没有找到该编号的商品!"<<'n'<<endl; cout<<"输入任意字符!继续" getch(); break; /修改商品信息void Commoditymassage:ModifyItem() /修改商品信息 char name20; commodity * p=NULL; cout<<"tt请输入要修改的商品的名称:
14、"cin>>name; if(p=FindItem(name) cout<<"tt已找到商品的信息,请输入新的信息!"<<endl; p->Next->Input(); cout<<"修改成功!"<<endl; cout<<"输入任意字符!继续" getch(); else cout<<"tt没有找到!"<<endl; cout<<"输入任意字符!继续" getch(
15、); /删除信息void Commoditymassage:RemoveItem() / 删除信息 char name20; commodity * p=NULL,*temp=NULL; cout<<"tt请输入要删除的商品的名称:"<<endl;cin>>name; if(p=FindItem(name) temp=p->Next; p->Next=p->Next->Next; delete temp; cout<<"tt删除成功!"<<endl; cout<&l
16、t;"输入任意字符!继续" getch(); else cout<<"tt没有找到!"<<endl; cout<<"输入任意字符!继续" getch(); /void Commoditymassage:S *p1, commodity *p2)/交换两个combox变量的数据域 commodity *temp=new commodity; strcpy(temp->name,p1->name); strcpy(temp->Id,p1->Id); temp->sale=p
17、1->sale; temp->buy=p1->buy; temp->sum=p1->sum; strcpy(p1->name,p2->name); strcpy(p1->Id,p2->Id); p1->sale=p2->sale; p1->buy=p2->buy; p1->sum=p2->sum; strcpy(p2->name,temp->name); strcpy(p2->Id,temp->Id); p2->sale=temp->sale; p2->buy=t
18、emp->buy; p2->sum=temp->sum;/int Commoditymassage:ListCount()/统计当前链表的记录总数,返回一个整数 if(! Head) return 0; int n=0; for(commodity * p=Head->Next;p!=End;p=p->Next) n+; return n;/void Commoditymassage:Sort()/对当前链表进行排序 cout <<"Sorting."<<endl; commodity *p=NULL,*p1=NULL,
19、*k=NULL; int n=Commoditymassage:ListCount(); if(n<2) return; for(p=Head->Next;p!=End;p=p->Next) for(k=p->Next;k!=End;k=k->Next) if(p->sum>k->sum) Commoditymassage:S); cout <<"排序完成!"<<endl; getch(); return;/保存函数void Commoditymassage:Save() out.open("
20、sort.txt"); for(commodity *p=Head->Next;p!=End;p=p->Next) out<<p->name<<"t"<<p->Id<<"t"<<p->sum<<'n' out.close();/主函数int main() int x,i=0; bool quit=false; cout<<"tt§§§§§§§§§§§§§§§§§§§§§§§§§§"<<endl; for(i=0;i<3;i+) cout<<"tttttttt "<
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 护理人员的领导力与团队建设
- 业务谈判技巧与谈判方案模板
- 城市绿化工程责任书(3篇)
- 护理知识科普:为健康护航为生命加油
- 护理查房中的护理教育
- 医疗废弃物处置保证承诺书3篇
- 财务部要求紧急提交资金流动报告函6篇
- 智能物流系统保障承诺函(4篇)
- 企业品牌形象视觉识别系统标准手册
- 按期交付期限维护承诺函9篇范文
- 北京建筑大学2016年高职升本科专业课考试试卷《城市轨道交通车辆构造》试卷
- 事业单位人事管理条例完整版x课件
- 中国地理概况-课件
- 高处作业安全技术交底-
- (部编版)五年级语文(下册)语文园地一·口语交际一优质课件
- 《导体和绝缘体》说课课件
- 小学劳动教育 二年级下册 活动《一起来种太阳花》(第二课时) 课件
- 零星交付操作规范指引
- 2022年书法五下教案河北美术出版社
- (完整PPT)春节习俗英文PPT课件
- 液氮杜瓦罐安全使用操作规程
评论
0/150
提交评论