class Commodity
{
public:
Commodity(string name,float price,int num,string producer,string brand);
void setNum(int num);
int getNum();
void setPrice(double price);
double getPrice();
private:
string name;
float price;
int num;
string producer;
string brand;
};
Commodity::Commodity(string name,float price,int num,string producer,string brand)
{
this->name=name;
this->price=price;
this->num=num;
this->producer=producer;
this->brand=brand;
}
void Commodity::setNum(int num)
{
this->num=num;
}
int Commodity::getNum()
{
return num;
}
void Commodity::setPrice(double price)
{
this->price=price;
}
double Commodity::getPrice()
{
return price;
}
Commodity foods=Commodity("食品"1.00,200,"生产商一","品牌一");
Commodity cosmetic=Commodity("化妆品"25.0,200,"生产商一","品牌一");
Commodity goods=Commodity("日用品"2.00,200,"生产商一","品牌一");
Commodity baverage=Commodity("饮料"2.50,200,"生产商一","品牌一");