#include <iostream>
#include <cstring>
using namespace std;
int monster_blood=10000;
//英雄
class Hero
{
protected:
string name;
int hp;
int attck;
public:
Hero()
{
//cout << "Hero的无参构造" << endl;
}
Hero(string name,int hp,int attck):name(name),hp(hp),attck(attck)
{
//cout << "Hero的有参构造" << endl;
}
virtual void Atk()
{
monster_blood-=0;
}
~Hero()
{
//cout << "Hero析构飞升" <<endl;
}
};
//法师
class Master:public Hero
{
private:
int ap_atk=50;
public:
Master()
{
//cout << "Master的无参构造" << endl;
}
Master(string name,int hp,int attck):Hero(name,hp,attck)
{
//cout << "Master调用Hero的有参函数" << endl;
}
virtual void Atk()
{
monster_blood-=(attck+ap_atk);
}
~Master()
{
//cout << "Master析构飞升" <<endl;
}
};
//射手
class Shooter:public Hero
{
private:
int ac_atk=100;
public:
Shooter()
{
//cout << "Shooter的无参构造" << endl;
}
Shooter(string name,int hp,int attck):Hero(name,hp,attck)
{
//cout << "Shooter调用Hero的有参函数" << endl;
}
virtual void Atk()
{
monster_blood-=(attck+ac_atk);
}
~Shooter()
{
//cout << "Shooter析构飞升" <<endl;
}
};
int main()
{
while(1)
{
Master F("谢佳征",100,500);
F.Atk();
if(monster_blood<=0)
{
cout << "怪兽--鸡基哥--升天" << endl;
break;
}
cout << "鸡基哥--剩余血量" << monster_blood << endl;
Shooter S("周蒙恩",100,1000);
S.Atk();
if(monster_blood<=0)
{
cout << "怪兽--鸡基哥--升天" << endl;
break;
}
cout << "鸡基哥--剩余血量" << monster_blood << endl;
}
return 0;
}