商场销售管理系统 C++课程设计 下载本文

内容发布更新时间 : 2024/12/25 22:24:00星期一 下面是文章的全部内容请认真阅读。

#endif

#include using namespace std; #include\#include

GoodsInfo::GoodsInfo() //构造函数 {

name=new char [21];

number=cost_p=unit_p=num_all=num_now=num_sell=cost_all=profit=0; next=NULL; }

GoodsInfo::GoodsInfo(char * a,int b,float c,float u,int all,int sell) //重载构造函数 {

strcpy(name,a); number=b; cost_p=c; unit_p=u; num_all=all; num_sell=sell; num_now=all-sell; cost_all=c*all; profit=(u-c)*sell; next=NULL; }

void GoodsInfo::operator= (const GoodsInfo &right) //重载= {

strcpy(name,right.name); number=right.number ; cost_p=right.cost_p; unit_p=right.unit_p ; num_all=right.num_all ; num_sell=right.num_sell ; num_now=right.num_now ; cost_all=right.cost_all; profit=right.profit ; }

void GoodsInfo::setInfo(char * a,float c,float u,int all,int sell) //数据载入

16

{

strcpy(name,a); cost_p=c; unit_p=u; num_all=all; num_sell=sell; num_now=all-sell; cost_all=c*all; profit=(u-c)*sell; next=NULL; }

void GoodsInfo::show(GoodsInfo * h) //显示 {

if(h==NULL) cout<<\else

{cout<<\<<\商品名: \cout<<\编号: \<<\成本: \<<\销售单价: \<<\销量:\<<\库存: \<<\已获得利润:\} }

void GoodsInfo:: Amend(GoodsInfo * h) //修改信息 { int F; char S;

cout<<\<<\商品成本单价 ^\<<\商品销售单价 ^\<<\进货数量 ^\<<\销售数量 ^\<<\do

{cout<<\请选择需要修改的项目编号:\cin>>F;

17

switch(F) {

case 1 :{cout<<\<<\请输入修改后的名称|\\n\

<<\cin.ignore ();

cin.getline(h->name,21);break;}

case 2 :{cout<<\<<\请输入修改后的成本价: \\n\

<<\cin>>h->cost_p;break;}

case 3 :{cout<<\请输入修改后的销售单价: \cin>>h->unit_p;break;}

case 4 :{cout<<\请输入修改后的进货量: \cin>>h->num_all;break;}

case 5 :{cout<<\请输入修改后的销售量: \cin>>h->num_sell;break;} }

h->cost_all=h->cost_p*(h->num_all); h->num_now=h->num_all -(h->num_sell); h->profit=(h->unit_p -(h->cost_p ))*h->num_sell; cout<<\是否需要继续修改?\cin>>S; }

while(S=='Y'); }

#include using namespace std; #include #include #include #include\GoodList::GoodList() {

p=new GoodsInfo [sizeof(GoodsInfo)]; head=NULL; p2=NULL; p->next =NULL;

18

//构造函数

}

GoodList::~GoodList() {

while(head!=NULL) {p=head; head=p->next ; delete [] p; } }

void GoodList::create() {int n=0; char f='Y';

cout<<\请输入商品信息:\while(f=='Y') {n+=1;

if(n==1) head=p; else

{p=new GoodsInfo [sizeof(GoodsInfo)]; p2->next=p; }

cout<<\商品名称: \if(n==1) cin.ignore (); cin.getline (p->name,21); cout<<\商品编号:\cin>>p->number; cout<<\成本价: \cin>>p->cost_p; cout<<\销售价: \cin>>p->unit_p; cout<<\共计商品件数: \cin>>p->num_all; cout<<\已售出商品件数: \cin>>p->num_sell;

p->num_now=p->num_all-(p->num_sell); p->cost_all=p->cost_p*(p->num_all);

p->profit=((p->unit_p)-(p->cost_p))*(p->num_sell); p2=p;

19

//析构函数

//创建

cout<<\是否继续输入?(输入‘Y’继续)\cin>>f; cin.ignore(); }

if(head!=NULL) p2->next=NULL; //P2指向最后一个 }

void GoodList::showinfo(GoodsInfo * h) //显示信息

{cout<

<

cout<name<number<cost_p<unit_p

<num_sell<num_now<profit<

h=h->next; }

}

GoodsInfo * GoodList::search() //查找 {

if(head==NULL) { cout<<\数据为空!\\n\else

{GoodsInfo *h; h=head; int f;

cout<<\<<\请选择查找方式: \\n\<<\按商品编号 \\n\cin>>f; switch(f) {case 1: { int x,y;

cout<<\请输入需查找的商品编号:\cin>>x;

20

<<\按商品名称 \

<<\