/*2015.烟台大学计算机与控制工程学院
*ALL rightreserved.
*文件名称:test.cpp
*作者:陈文浩
*完成日期:2016年4月21日。
*/
/*问题及代码:
将上一周“项目2-带武器的游戏角色”用“一个项目多个文件”的方式实现,其中两个类的声明放在一个.h文件中,每个类的成员函数分别放一个文件,main()函数用一个文件。体会这样安排的优点。
*/
#ifndef GAME_H_INCLUDED
#define GAME_H_INCLUDED
using namespace std;
class Weapon
{
public:
Weapon(string wnam, int f);
int getForce();
private:
string wname; //名称
int force; //威力
};
class Role
{
public:
Role(string nam, int b, string wnam, int f); //构造函数
~Role(); //析构函数
void eat(int d); //吃东西,涨d血
void attack(Role &r); //攻击别人,自己涨血,同时失血
bool isAlived(); //是否活着
void show(); //显示
private:
string name;
int blood;
Weapon weapon;
bool life;
};
#endif // GAME_H_INCLUDED