Kod :
public int health,
public int maxHealth
no i tworze sobie te kreatury i chce zrobic funkcje ktora pobeira ich hp czyli:
Kod :
public int getHealth()
{
return health;
}
Kod :
public int getHealth(creature)
{
return creature.health;
}
Tak dla wizualizacji, postac tworze w nastepujacy sposob;
Kod :
Character Postac = new Character("Arkam", 100, 100, 0, 1,1,1,1,0,-1);
##edit
zrobilem tak xd juz chyba nvm
Kod :
public class Functions {
public int getHealth(Character creature)
{
return creature.health;
}
public int getHealth(Enemy creature)
{
return creature.health;
}
}
//Przyklad_1
Functions funkcje = new Functions ();
funkcje.getHealth (Postac);
//Przyklad_2
Functions funkcje = new Functions ();
funkcje.getHealth(Przeciwnik);
Zakładki