一。今日所学 二。作用 #include <iostream>
using namespace std;
int blood=10000;
class hero
{
protected:
string name;
int hp;
int attack;
public:
hero(){}
hero(string name,int hp,int attack):name(name),hp(hp),attack(attack)
{
}
virtual void Atk()
{
blood-=50;
}
};
class mage:public hero
{
private:
int ap_atk=50;
public:
mage(){}
mage(string name,int hp,int attack,int ap_atk):hero(name,hp,attack),ap_atk(ap_atk)
{
}
void Atk()
{
blood-=(attack+ap_atk);
}
};
class shooter:public hero
{
private:
int ac_atk=100;
public:
shooter(){}
shooter(string name,int hp,int attack,int ac_atk):hero(name,hp,attack),ac_atk(ac_atk)
{
}
void Atk()
{
blood-=(attack+ac_atk);
}
};
int main()
{
char ss;
mage mt("li shi",1,30,50);
shooter st("zhang san",1,20,100);
while(blood>0)
{
cin >> ss;
if(ss=='f'||ss=='F')
mt.Atk();
else if(ss=='j' || ss=='J')
st.Atk();
else
blood-=30;
cout <<blood<<endl;
}
return 0;
}