zidongshouhuoji.h

来自「VC各工程的源码集合」· C头文件 代码 · 共 68 行

H
68
字号
class shouyinji
{
public:
	int cashNow();//返回当前的现金
	void acceptAmount(int acceptcash);//接受付款
	shouyinji(int amount=500);//初始化
private:
	int cash;
};

class shouhuoji
{
public:
	int amount();
	int price();
	void makesale();
	shouhuoji(int numberofproduct=100,
		      int costofproduct=2);//初始化
private:
	int number;
	int cost;
};

int shouyinji::cashNow()
{
	return cash;
}//显示收银机里现有的现金
	
void shouyinji::acceptAmount(int acceptcash)
{
	 cash+=acceptcash;
}

shouyinji::shouyinji(int amount)
{
	if(amount>=0)
		cash=amount;
	else
		cash=100;
}

int shouhuoji::amount()
{
	return number;
}

int shouhuoji::price()
{
	return cost;
}

void shouhuoji::makesale(){
	number--;
}//每售出一件数量减一

shouhuoji::shouhuoji(int numberofproduct,int costofproduct)
{
	if(numberofproduct>0)
		number=numberofproduct;
	else
		number=100;
	if(costofproduct>=0)
		cost=costofproduct;
	else
		cost=2;
}//初始化

	

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?