class Enemy
{
private:
int hp; // current hp
int maxhp; // max hp
int strength; // strength
public:
// a function called when the Enemy has to choose an action
Action GetAction()
{
if((hp * 4) < maxhp) // if we have less than 25% hp
{
return Action("Run Away"); // try to run away
}
// otherwise, pick an attack at random
if((rand() % 8) != 0)
{
return Action( "Normal Attack", strength );
}
else
{
return Action( "Super Special Move", strength * 2 );
}
}
};
I suppose you weren't aware that you can create an arbitrary number of class instances and that each instance has its own copy of that variable, otherwise your question would make little sense.