I want to program a small game in C++.
I want to write a method "attack" that sets the states of the figure after an attack. I have two instances the player and the enemy. The class looks like:
class figure {
private:
string name;
int hp;
int strength;
int defense;
public:
void attack(int xstrength) {
// This method gets the Input values of the player and should calculate
// and set the new hp stats of the enemy after an attack, sort of
hp = hp - (xstrength - defense);
}
};
But how can I call this methode? Do i need to programm a separate methode that only gets the srength value of an instance?, because I cant call the instances this way:
enemy.attack();
Because I need to Input the strength of the instance player. Or can i only access one value of an instance such like
enemy.attack(player->get_xstrength)
with the method:
void get_strength() {
return stength
};
If I extend the class figure with more values like, resistance, level, status etc. I must program a lot of get and set methodes.