I am working on a simple video game program for school and I have created a method where the player gets 15 health points if that method is called. I have to keep the health at
I know this is a school project, but if you wanted to expand your game later on and be able to upgrade your healing power, write the function like so:
public void getHealed(healthPWR) {
health = Math.min(health + healthPWR, 100);
}
and call out the function:
getHealed(15);
getHealed(25);
...etc...
Furthermore you can create your max HP by creating a variable that is not local to the function. Since I don't know what language you're using, I will not show an example because it might have the wrong syntax.