#include <iostream>
using namespace std;
int blood = 10000; //纳什男爵的血量
class Hero //英雄类
{
public:
string name;
protected:
int hp; //血量
int attack; //攻击力
public:
Hero() {}
Hero(string n, int h, int a):name(n), hp(h), attack(a) {}
virtual void rush()
{
blood -= 0;
}
};
//定义刺客类,继承自英雄类
class Assassin : public Hero
{
protected:
int add_attack = 100;
public:
Assassin() {}
Assassin(string n, int h, int a):Hero(n, h, a) {}
~Assassin() {}
//重写打野函数
void rush() override
{
blood -= (attack + add_attack);
}
};
//定义一个法师类,继承自英雄类
class Master : public Hero
{
protected:
int add_attack = 10;
public:
Master() {}
Master(string n, int h, int a):Hero(n, h, a) {}
~Master() {}
//重写打野函数
void rush() override
{
blood -= (attack + add_attack);
}
};
//定义全局函数,打野
void fun(Hero &h)
{
h.rush();
cout<<"男爵正在被"<<h.name<<"攻击,剩余血量:"<<blood<<endl;
}
int main()
{
Assassin a1("韩信", 2000, 500);
Master m1("妲己", 1200, 200);
while(blood > 0)
{
fun(a1);
fun(m1);
_sleep(1000);
}
return 0;
}