商店进存销管理系统C++
来源:互联网 发布:java调用类里面的方法 编辑:程序博客网 时间:2024/04/30 16:38
定义的外部变量:
#include "stdafx.h"
#include <iostream>
#include <string>
using namespace std;
int n=0;
int chemise_n=0;
int cabinet_n=0;
int hat_n=0;
定义的货物头文件:
#include "stdafx.h"
#include <iostream>
#include <string>
using namespace std;
extern int n;
extern int chemise_n;
extern int cabinet_n;
extern int hat_n;
class Goods
{
public:
char gn[40];
char gi[40];
char* goodsname;
char* goodsId;
float buyin;//当前进货
float sellout;//当前出货
float weight;//当前总库存
float totalbuyin;//总进货
float totalsellout;//总出货
public:
Goods()
{
buyin=0;
weight=0;
sellout=0;
totalbuyin=0;
totalsellout=0;
}
/*Goods(char* gn,char* gi,float gw=0,float b=0,float s=0)
{
strcpy(goodsname,gn);
strcpy(goodsId,gi);
weight=gw;
buyin=b;
sellout=s;
}*/
void setgn();
void buy();
void sell();
float total(); //显示当前货物的库存
void show();
protected:
};
void Goods::setgn()
{
cout<<"请输入货物名:";
cin>>gn;
cout<<"请输入货物条形码:";
cin>>gi;
cout<<"请输入货物重量:";
cin>>buyin;
/*cout<<strlen(gn)+1<<endl;*/
/*cout<<goodsname<<endl;
cout<<goodsId<<endl;
cout<<&goodsname<<endl;
cout<<&goodsId<<endl;
show();*/
weight=buyin;
totalbuyin=buyin;
}
void Goods::buy()
{
float b;
cout<<"请输入卖入货物的重量 :";
cin>>b;
totalbuyin=totalbuyin+b;
weight=weight+b;
cout<<"此次进货"<<b<<"千克"<<endl;
cout<<"到目前为止,总进货量为:"<<totalbuyin<<"千克"<<endl;
}
void Goods::sell()
{
float s;
cout<<"请输入卖出货物的重量 :";
cin>>s;
totalsellout=totalsellout+s;
weight=weight-s;
cout<<"此次卖出货物"<<s<<"千克"<<endl;
cout<<"到目前为止,总销货量为:"<<totalsellout<<"千克"<<endl;
}
float Goods::total()
{
return weight;
}
void Goods::show()
{
cout<<goodsId<<" "<<goodsname<<" "<<weight<<" 千克"<<endl;
}
class chemise
{
public:
char gn[40];
char gi[40];
float price ;
char product_area[50];
char materiel[20];
char* goodsname;
char* goodsId;
int buyin;//当前进货
int sellout;//当前出货
int amount;
int totalbuyin;//总进货
int totalsellout;//总出货
chemise()
{
price=0;
buyin=0;
amount=0;
sellout=0;
totalbuyin=0;
totalsellout=0;
}
void setgn();
void set_materiel();
void buy();
void sell();
float total(); //显示当前货物的库存
void show();
};
void chemise::setgn()
{
cout<<"请输入货物名:";
cin>>gn;
cout<<"请输入货物条形码:";
cin>>gi;
cout<<"请输入单价:";
cin>>price;
cout<<"请输入产地:";
cin>>product_area;
cout<<"请输入货物数量:";
cin>>buyin;
amount=buyin;
totalbuyin=buyin;
}
void chemise::set_materiel()
{
cout<<"请输入布料:";
cin>>materiel;
}
void chemise::buy() //买进货物函数
{
float b;
cout<<"请输入买入货物的数量 :";
cin>>b;
totalbuyin=totalbuyin+b;
amount=amount+b;
cout<<"此次进货"<<b<<"个"<<endl;
cout<<"到目前为止,总进货量为:"<<totalbuyin<<"个"<<endl;
}
void chemise::sell()//卖出货物函数
{
float s;
cout<<"请输入卖出货物的数量 :";
cin>>s;
totalsellout=totalsellout+s;
amount=amount-s;
cout<<"此次卖出货物"<<s<<"个"<<endl;
cout<<"到目前为止,总销货量为:"<<totalsellout<<"个"<<endl;
}
float chemise::total()//库存货物函数
{
return amount;
}
void chemise::show()
{
}
class hat:public chemise //派生
{
public:
char style[20];
public:
hat()
{
buyin=0;
amount=0;
sellout=0;
totalbuyin=0;
totalsellout=0;
}
void set_style() //设置帽子的样式函数
{
cout<<"请输入样式(平顶或尖顶):";
cin>>style;
}
};
class cabinet:public chemise
{
public:
char style[20];
public:
cabinet(){price=0;
buyin=0;
amount=0;
sellout=0;
totalbuyin=0;
totalsellout=0;}
void set_materiel()
{
cout<<"请输入木料:";
cin>>materiel;
}
void set_style()
{
cout<<"请输入颜色:";
cin>>style;
}
};
定义的商店类:
#include "stdafx.h"
#include <iostream>
#include "goods.h"
#include <string>
#include "exbianliang.h"
using namespace std;
extern int n;
extern int chemise_n;
extern int cabinet_n;
extern int hat_n;
class Shop
{
public:
Goods huowu[20];
chemise chenyi[20];
hat maozi[20];
cabinet ligui[20];
Shop(char* shopn,char* shopb);
void setshopn();
void setboss();
void delg();
void show_g();
void show_c();
void show_h();
void show_cabinet();
void show();
protected:
private:
char* shopname ;
char* boss;
};
Shop::Shop(char *shopn, char *shopb)
{
shopname=new char[strlen(shopn)+1];
strcpy(shopname,shopn);
boss=new char[strlen(shopb)+1];
strcpy(boss,shopb);
}
void Shop::setshopn()
{ char* shopn= new char[40];
cout<<"请输入店名:";
cin>>shopn;
strcpy(shopname,shopn);
}
void Shop::setboss()
{
char* shopb= new char[40];
cout<<"请输入店主名:";
cin>>shopb;
strcpy(boss,shopb);
}
void Shop::delg()
{
int delglei;
cout<<"请输入要删除货物的类别号:";
cin>>delglei;
switch(delglei)
{
case 0:
int delgID;
cout<<"请输入你要删除的货物的序号!"<<"序号:";
cin>>delgID;
huowu[delgID]=huowu[n-1];
n--;
break;
case 1:
int delgID1;
cout<<"请输入你要删除的货物的序号!"<<"序号:";
cin>>delgID1;
chenyi[delgID1]=chenyi[chemise_n];
chemise_n--;
break;
case 2:
int delgID2;
cout<<"请输入你要删除的货物的序号!"<<"序号:";
cin>>delgID2;
maozi[delgID2]=maozi[hat_n];
hat_n--;
break;
case 3:
int delgID3;
cout<<"请输入你要删除的货物的序号!"<<"序号:";
cin>>delgID3;
ligui[delgID3]=ligui[hat_n];
cabinet_n--;
break;
default:
break;
}
}
void Shop::show_g()
{
int i,j,k,gidn,gnn;
cout<<" 0 、重量类"<<endl;
cout<<"序号"<<" 货物条形码 "<<"货物名称 "<<"总数"<<endl;
for (i=0;i<n;i++)
{
gidn=15-strlen(huowu[i].gi);
gnn=15-strlen(huowu[i].gn);
cout<<i<<" "<<huowu[i].gi;
for (j=0;j<gidn;j++)
{
cout<<' ';
}
cout<<(huowu[i].gn);
for (k=0;k<gnn;k++)
{
cout<<' ';
}
cout<<huowu[i].weight<<endl;
}
}
void Shop::show_h()
{
int i;
cout<<" 2 、帽子类"<<endl;
cout<<"序号"<<" 货物条形码"<<" 货物名称"<<" 总数"<<" 单价"<<" 布料"<<" 样式"<<" 产地"<<endl;
for (i=0;i<hat_n;i++)
{
int j=0,k=0,gidn=0,gnn=0,m=0,n=0,p=0,s=0,amout_n=0,amout_a=0,int_price=0,price_n=0;
gidn=12-strlen(maozi[i].gi);
gnn=10-strlen(maozi[i].gn);
cout<<i<<" "<<maozi[i].gi;
for (j=0;j<gidn;j++)
{
cout<<' ';
}
cout<<(maozi[i].gn);
for (k=0;k<gnn;k++)
{
cout<<' ';
}
cout<<maozi[i].amount;
amout_a=maozi[i].amount;
while (amout_a)
{
amout_a=amout_a/10;
amout_n++;
}
for (j=0;j<(6-amout_n);j++)
{
cout<<' ';
}
cout<<maozi[i].price;
int_price=maozi[i].price;
while (int_price)
{
int_price=int_price/10;
price_n++;
}
for (j=0;j<(6-price_n);j++)
{
cout<<' ';
}
cout<<maozi[i].materiel;
for (p=0;p<(6-(strlen(maozi[i].materiel)));p++)
{
cout<<' ';
}
cout<<maozi[i].style;
for (j=0;j<(6-(strlen(maozi[i].style)));j++)
{
cout<<' ';
}
cout<<maozi[i].product_area<<endl;
}
}
void Shop::show_c()
{
int i;
cout<<" 1 、衬衣类"<<endl;
cout<<"序号"<<" 货物条形码"<<" 货物名称"<<" 总数"<<" 单价"<<" 布料"<<" 产地"<<endl;
for (i=0;i<chemise_n;i++)
{
int j=0,k=0,gidn=0,gnn=0,m=0,n=0,p=0,s=0,amout_n=0,amout_a=0,int_price=0,price_n=0;
gidn=12-strlen(chenyi[i].gi);
gnn=10-strlen(chenyi[i].gn);
cout<<i<<" "<<chenyi[i].gi;
for (j=0;j<gidn;j++)
{
cout<<' ';
}
cout<<(chenyi[i].gn);
for (k=0;k<gnn;k++)
{
cout<<' ';
}
cout<<chenyi[i].amount;
amout_a=chenyi[i].amount;
while (amout_a)
{
amout_a=amout_a/10;
amout_n++;
}
for (j=0;j<(6-amout_n);j++)
{
cout<<' ';
}
cout<<chenyi[i].price;
int_price=chenyi[i].price;
while (int_price)
{
int_price=int_price/10;
price_n++;
}
for (j=0;j<(6-price_n);j++)
{
cout<<' ';
}
cout<<chenyi[i].materiel;
for (p=0;p<(5-strlen(chenyi[i].materiel));p++)
{
cout<<' ';
}
cout<<chenyi[i].product_area<<endl;
}
}
void Shop::show_cabinet()
{
int i;
cout<<" 3 、柜子类"<<endl;
cout<<"序号"<<" 货物条形码"<<" 货物名称"<<" 总数"<<" 单价"<<" 木料"<<" 颜色"<<" 产地"<<endl;
for (i=0;i<cabinet_n;i++)
{
int j=0,k=0,gidn=0,gnn=0,m=0,n=0,p=0,s=0,amout_n=0,amout_a=0,int_price=0,price_n=0;
gidn=12-strlen(ligui[i].gi);
gnn=10-strlen(ligui[i].gn);
cout<<i<<" "<<ligui[i].gi;
for (j=0;j<gidn;j++)
{
cout<<' ';
}
cout<<(ligui[i].gn);
for (k=0;k<gnn;k++)
{
cout<<' ';
}
cout<<ligui[i].amount;
amout_a=ligui[i].amount;
while (amout_a)
{
amout_a=amout_a/10;
amout_n++;
}
for (j=0;j<(6-amout_n);j++)
{
cout<<' ';
}
cout<<ligui[i].price;
int_price=ligui[i].price;
while (int_price)
{
int_price=int_price/10;
price_n++;
}
for (j=0;j<(6-price_n);j++)
{
cout<<' ';
}
cout<<ligui[i].materiel;
for (p=0;p<(6-strlen(ligui[i].materiel));p++)
{
cout<<' ';
}
cout<<ligui[i].style;
for (j=0;j<(6-strlen(ligui[i].style));j++)
{
cout<<' ';
}
cout<<ligui[i].product_area<<endl;
}
}
void Shop::show()
{
cout<<" 商店名:"<<shopname<<" 店主:"<<boss<<endl<<endl<<endl;
show_g();
show_c();
show_h();
show_cabinet();
}
要用到的头文件:// stdafx.h : 标准系统包含文件的包含文件,
// 或是经常使用但不常更改的
// 特定于项目的包含文件
//
#pragma once
#define WIN32_LEAN_AND_MEAN // 从 Windows 头中排除极少使用的资料
#include <stdio.h>
#include <tchar.h>
// TODO: 在此处引用程序需要的其他头文件
附加的cpp文件:
// stdafx.cpp : 只包括标准包含文件的源文件
// exercise01.pch 将作为预编译头
// stdafx.obj 将包含预编译类型信息
#include "stdafx.h"
// TODO: 在 STDAFX.H 中
// 引用任何所需的附加头文件,而不是在此文件中引用
主文件:
#include "stdafx.h"
#include <iostream>
#include "shop.h"
#include <string>
using namespace std;
extern int n;
extern int chemise_n;
extern int cabinet_n;
extern int hat_n;
extern int n;
int main()
{
int b_x=1;
int i;
static char* shop_name= new char[100];
static char* boss_name= new char[40];
cout<<"请输入的店名,老板名!"<<endl;
cin>>shop_name>>boss_name;
//cout<<shop_name<<boss_name<<endl;
Shop zhao_shop(shop_name,boss_name);
for (i=0;i<n;i++)
{
cout<<"请输入第"<<i+1<<"个货物,条形码,货物重量 !"<<endl;
(zhao_shop.huowu[i]).setgn();
}
while(b_x)
{
int x;
cout<<"请输入 :"<<endl;
cout<<" 0 、显示所有的商品信息"<<endl;
cout<<" 1 、卖出货物"<<endl;
cout<<" 2 、购进货物"<<endl;
cout<<" 3 、增加品种"<<endl;
cout<<" 4 、减少品种"<<endl;
cin>>x;
switch(x)
{
case 0:
zhao_shop.show();
break;
case 1:
int i,j;
cout<<"请输入要卖出的货物类别号:";
cin>>i;
cout<<"请输入要卖出的货物类中序号:";
cin>>j;
switch(i)
{
case 0:
zhao_shop.huowu[j].sell();
break;
case 1:
zhao_shop.chenyi[j].sell();
break;
case 2:
zhao_shop.maozi[j].sell();
break;
case 3:
zhao_shop.ligui[j].sell();
break;
default:
break;
}
break;
case 3:
int k;
cout<<"请输入要增加货物品种类别号:";
cin>>k;
switch(k)
{
case 0:
zhao_shop.huowu[n].setgn();
n++;
break;
case 1:
zhao_shop.chenyi[chemise_n].setgn();
zhao_shop.chenyi[chemise_n].set_materiel();
chemise_n++;
break;
case 2:
zhao_shop.maozi[hat_n].setgn();
zhao_shop.maozi[hat_n].set_materiel();
zhao_shop.maozi[hat_n].set_style();
hat_n++;
break;
case 3:
zhao_shop.ligui[cabinet_n].setgn();
zhao_shop.ligui[cabinet_n].set_materiel();
zhao_shop.ligui[cabinet_n].set_style();
cabinet_n++;
break;
default:
break;
}
break;
case 2:
int m,n;
cout<<"请输入要买进的货物类别号:";
cin>>m;
cout<<"请输入要买进的货物类中序号:";
cin>>n;
switch(m)
{
case 0:
zhao_shop.huowu[n].buy();
break;
case 1:
zhao_shop.chenyi[n].buy();
break;
case 2:
zhao_shop.maozi[n].buy();
break;
case 3:
zhao_shop.ligui[n].buy();
break;
default:
break;
}
n++;
break;
case 4:
zhao_shop.delg();
break;
default :
break;
}
cout<<endl<<"请输入 0 退出!非 0 整数继续操作! !/n";
cin>>b_x;
}
}
- 商店进存销管理系统C++
- 商店商品管理系统
- 商店货物管理系统
- 商店管理系统代码
- 商店管理系统源代码(一)
- 商店管理系统源代码(二)
- 商店管理系统源代码(三)
- 商店管理系统源代码(四)
- 商店管理系统源代码(五)
- 商店管理系统源代码(六)
- 商店管理系统源代码(七)
- 商店管理系统源代码(八)
- 商店管理系统源代码(九)
- 商店管理系统源代码(十)
- 商店管理系统源代码(十一)
- 商店管理系统源代码(十二)
- 商店管理系统源代码(十三)
- 商店管理系统源代码(十四)
- 泛型设计(1)
- GCC 下 C和ASM混合编程
- 腾讯一道找中位数的面试题
- ZOJ-2110 Tempter of the Bone( 搜索,奇偶性剪枝)
- 我将终止对CSDN上传系统的支持
- 商店进存销管理系统C++
- Linux 汇编语言开发指南
- 工作了三年,心的转点
- 越来越懒
- 2. Singleton单件(创建型模式)
- Drawing an Image:画一幅图
- TWebBrowser 与 MSHTML(5): document 对象的属性、方法、事件纵览
- Eclipse中集成Ant实现快速开发
- IE8开发人员工具使用详解下(浏览器模式、JavaScript调试)