商品的管理系统

/*烟台大学计算机学院学生
*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;
}

运行结果:


  • 0
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
YOLO高分设计资源源码,详情请查看资源内容中使用说明 YOLO高分设计资源源码,详情请查看资源内容中使用说明 YOLO高分设计资源源码,详情请查看资源内容中使用说明 YOLO高分设计资源源码,详情请查看资源内容中使用说明YOLO高分设计资源源码,详情请查看资源内容中使用说明YOLO高分设计资源源码,详情请查看资源内容中使用说明YOLO高分设计资源源码,详情请查看资源内容中使用说明YOLO高分设计资源源码,详情请查看资源内容中使用说明YOLO高分设计资源源码,详情请查看资源内容中使用说明YOLO高分设计资源源码,详情请查看资源内容中使用说明YOLO高分设计资源源码,详情请查看资源内容中使用说明YOLO高分设计资源源码,详情请查看资源内容中使用说明YOLO高分设计资源源码,详情请查看资源内容中使用说明YOLO高分设计资源源码,详情请查看资源内容中使用说明YOLO高分设计资源源码,详情请查看资源内容中使用说明YOLO高分设计资源源码,详情请查看资源内容中使用说明YOLO高分设计资源源码,详情请查看资源内容中使用说明YOLO高分设计资源源码,详情请查看资源内容中使用说明YOLO高分设计资源源码,详情请查看资源内容中使用说明YOLO高分设计资源源码,详情请查看资源内容中使用说明YOLO高分设计资源源码,详情请查看资源内容中使用说明YOLO高分设计资源源码,详情请查看资源内容中使用说明YOLO高分设计资源源码,详情请查看资源内容中使用说明YOLO高分设计资源源码,详情请查看资源内容中使用说明YOLO高分设计资源源码,详情请查看资源内容中使用说明YOLO高分设计资源源码,详情请查看资源内容中使用说明

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值