商品的管理系统
2014-05-22 22:48
155 查看
/*烟台大学计算机学院学生 *All right reserved. *文件名称:商品的管理系统 *作者:杨飞 *完成日期:2014年5月20日 *版本号:v1.0 *对任务及求解方法的描述部分:商品的管理系统 *我的程序:*/ #include <iostream> #include <cstring> #include <iomanip> #include <cstdlib> using namespace std; class Product { private: int hao; string name; string pin; string xing; double price; public: void add(); void findgood(); void findquan(); void genhao(); void genname(); void genpin(); void genxing(); void display(); void welcomeframe(); }; int size=0; Product product[100000]; void Product::welcomeframe() { cout<<"|---------------------------|"<<endl; cout<<"|--------商品管理系统-------|"<<endl; cout<<"|---------------------------|"<<endl; cout<<"|--------1.增加商品---------|"<<endl; cout<<"|--------2.查找商品---------|"<<endl; cout<<"|--------3.查找全部商品-----|"<<endl; cout<<"|--------4.退出系统---------|"<<endl; cout<<"|---------------------------|"<<endl; cout<<"请输入指令:"<<endl; int n; cin>>n; switch(n) { case 1: add(); break; case 2: findgood(); break; case 3: findquan(); break; case 4: exit(0); } } void Product::add() { char n; cout<<"输入商品编号:"; cin>>product[size].hao; cout<<"输入商品名称:"; cin>>product[size].name; cout<<"输入商品品牌:"; cin>>product[size].pin; cout<<"输入商品型号:"; cin>>product[size].xing; cout<<"输入价格:"; cin>>product[size].price; cout<<"添加成功!"<<endl; product[size].display(); size++; cout<<"是否继续添加图书(是y,否n)"<<endl; cin>>n; if(n=='y') Product::add(); if(n=='n') welcomeframe(); } void Product::genhao() { int n,h=1; cout<<"请输入你想查找的编号:"<<endl; cin>>n; for(int i=0;i<size;i++) { if(product[i].hao==n) { product[i].display(); h=2; } if(h==1) cout<<"查无此物!"<<endl; } welcomeframe(); } void Product::findgood() { cout<<"|---------------------------------|"<<endl; cout<<"|--------1.以商品编号查找---------|"<<endl; cout<<"|--------2.以商品名查找-----------|"<<endl; cout<<"|--------3.以商品品牌查找-----------|"<<endl; cout<<"|--------4.以商品型号查找-----------|"<<endl; cout<<"|--------5.回到主菜单-------------|"<<endl; cout<<"|---------------------------------|"<<endl; cout<<"请输入指令:"; int n; cin>>n; switch(n) { case 1: genhao(); break; case 2: genname(); break; case 3: genpin(); break; case 4: genxing(); break; case 5: welcomeframe(); break; } } void Product::findquan() { for(int i=0;i<size;i++) { product[i].display(); } welcomeframe(); } void Product::genname() { int h=1; string n; cout<<"请输入你想查找的商品名字:"<<endl; cin>>n; for(int i=0;i<size;i++) { if(product[i].name==n) { product[i].display(); h=2; } if(h==1) cout<<"查无此物!"<<endl; } welcomeframe(); } void Product::genpin() { int h=1; string n; cout<<"请输入你想查找的商品品牌:"<<endl; cin>>n; for(int i=0;i<size;i++) { if(product[i].pin==n) { product[i].display(); h=2; } if(h==1) cout<<"查无此物!"<<endl; } welcomeframe(); } void Product::genxing() { int h=1; string n; cout<<"请输入你想查找的商品型号:"<<endl; cin>>n; for(int i=0;i<size;i++) { if(product[i].xing==n) { product[i].display(); h=2; } if(h==1) cout<<"查无此物!"<<endl; } welcomeframe(); } void Product::display() { cout<<"+-----------------------------------------------------------------------+"<<endl; cout<<setiosflags(ios::left)<<"+"<<setw(10)<<"商品编号"<<setw(10)<<"商品名称"<<setw(10)<<"品牌"<<setw(10)<<"型号"<<setw(10)<<"价格"<<setw(3)<<"|"<<endl; cout<<"|-----------------------------------------------------------------------|"<<endl; for(int i=0;i<size;i++) { cout<<setiosflags(ios::left)<<"|"<<setw(10)<<product[i].hao<<setw(10)<<product[i].name<<setw(10)<<product[i].pin<<setw(10)<<product[i].xing<<setw(10)<<product[i].price<<setw(3)<<"|"<<endl; } } int main() { Product p; p.welcomeframe(); return 0; }
运行结果:
相关文章推荐
- 商店商品管理系统
- 商品销售管理系统设计论文--毕业设计
- 电商系统中商品属性管理
- 商品信息管理系统
- C语言编写的商品管理系统
- 商品管理录入管理系统
- 承志医疗管理系统技术解析设置商品折扣率(九)
- 商品管理系统--分类、品牌、属性、商品、价格、图片管理
- C++学习第2天 简单的商品管理系统
- 用C语言编写的超市商品信息管理系统
- C#程序(商品管理系统)
- 软件项目管理系统-采购商品管理-应用流程
- 软件项目管理系统-采购商品管理-三权分立
- 用C语言编写的商品库存管理系统
- 商品管理系统
- 商品管理系统
- 软件项目管理系统-采购商品管理-项目商品一览
- 软件项目管理系统-采购商品管理-采购订单一览
- S1 商品信息管理系统
- PHP基础示例:商品信息管理系统v1.1[转]