#include<iostream>
#include<vector>
#include<iomanip>
#include<string>
#include<fstream>
#include <time.h>
using namespace std;
class CGoods {
int index;
double price;
public:
string goodsname;
CGoods(int in,string na,double pr):index(in),goodsname(na),price(pr) {}
~CGoods() {}
string Getname();
int Getindex();
void Setprice(double);
double Getprice();
CGoods *Clone();
};
//CGoods的实现
string CGoods::Getname() { //获取商品名字
return goodsname;
}
int CGoods::Getindex() { //获取商品索引号
return index;
}
void CGoods::Setprice(double uprice) { //设置商品单价
price=uprice;
}
double CGoods::Getprice() { //获取商品单价
return price;
}
CGoods *CGoods::Clone() { //复制商品信息
return new CGoods(index,goodsname,price);
}
typedef struct tagStoreElement { //货架元素
CGoods *pGoods;
int iNum;
} StoreElement,*pStoreElement;
//类CStore的定义
class CStore {
private:
vector<pStoreElement> m_vStore;
public:
CStore() {}
~CStore() {
Deleteall();
}
bool AddGoods(CGoods *,int);
int FindGoods(int);
void DeleteGoods(string,int);
void DeleteGoods(int,int);
void Deleteall();
vector<pStoreElement>* getAllGoods();
pStoreElement getGoods(int);
void Print();
};
//CStore的实现
bool CStore::AddGoods(CGoods *pGoods, int iNum) { //添加商品
int size = m_vStore.size();
bool exist = false;
if ( !exist ) { //没有同类商品,则增加此类商品
pStoreElement p = new StoreElement;
p->pGoods= pGoods;
p->iNum=iNum;
m_vStore.push_back(p);
}
for(int i=0; i<size; i++) {
pStoreElement pSE=m_vStore[i];
if(pSE->pGoods!=NULL&&pSE->pGoods->Getindex()==pGoods->Getind
#include<vector>
#include<iomanip>
#include<string>
#include<fstream>
#include <time.h>
using namespace std;
class CGoods {
int index;
double price;
public:
string goodsname;
CGoods(int in,string na,double pr):index(in),goodsname(na),price(pr) {}
~CGoods() {}
string Getname();
int Getindex();
void Setprice(double);
double Getprice();
CGoods *Clone();
};
//CGoods的实现
string CGoods::Getname() { //获取商品名字
return goodsname;
}
int CGoods::Getindex() { //获取商品索引号
return index;
}
void CGoods::Setprice(double uprice) { //设置商品单价
price=uprice;
}
double CGoods::Getprice() { //获取商品单价
return price;
}
CGoods *CGoods::Clone() { //复制商品信息
return new CGoods(index,goodsname,price);
}
typedef struct tagStoreElement { //货架元素
CGoods *pGoods;
int iNum;
} StoreElement,*pStoreElement;
//类CStore的定义
class CStore {
private:
vector<pStoreElement> m_vStore;
public:
CStore() {}
~CStore() {
Deleteall();
}
bool AddGoods(CGoods *,int);
int FindGoods(int);
void DeleteGoods(string,int);
void DeleteGoods(int,int);
void Deleteall();
vector<pStoreElement>* getAllGoods();
pStoreElement getGoods(int);
void Print();
};
//CStore的实现
bool CStore::AddGoods(CGoods *pGoods, int iNum) { //添加商品
int size = m_vStore.size();
bool exist = false;
if ( !exist ) { //没有同类商品,则增加此类商品
pStoreElement p = new StoreElement;
p->pGoods= pGoods;
p->iNum=iNum;
m_vStore.push_back(p);
}
for(int i=0; i<size; i++) {
pStoreElement pSE=m_vStore[i];
if(pSE->pGoods!=NULL&&pSE->pGoods->Getindex()==pGoods->Getind