商店经销一种货物,货物成箱购进,成箱卖出,购进和卖出时以重量为单位,各箱的重量不一样,单价不一样,因此商店需要记录下目前库存的货物的总重量和总价值。编写一个程序,通过定义类Carlo来模拟商店货物购进和卖出的情况。
//Menu.h
#ifndef MENU_H
#define MENU_H
class Menu
{public:
int show();
};
#endif;
// Carlo.h
class Carlo
{public:
Carlo(double Weight = 0,double Price = 0);
virtual ~Carlo();
void SetCarlo(double = 0,double = 0);
const double &GetCurrentTotalWeight() const;
const double &GetCurrentTotalPrice() const;
void BuyBox();
void SellBox();
void ShowBoxInfor() const;
protected:
static double TotalWeight;
static double TotalPrice;
private:
double BoxWeight;
double BoxPrice;
};
//Carlo.cpp
#include <iostream>
#include "Carlo.h"