I created a test project, but I encountered something I can't figure out.
I am trying to call Monster in FightManager. I want Monster's variables (name, health, damage and defense) to be equal to whatever monster is randomized (WolfMonster or GoblinMonster)
Previously I had only one monster, and I managed to do it but now when there are 2 monsters how can I pass the variables a different value if a different monster is selected?
public class Units {
int health;
int damage;
int defense;
String name;
public boolean isAlive(){
if(health >= 1){
return true;
}else{
return false;
}
}
}
public class Monster extends Units{
public Monster(String name,int health,int damage,int defense){
this.name = name;
this.health = health;
this.damage = damage;
this.defense = defense;
}
}
public class GoblinMonster extends Monster {
public GoblinMonster(String name, int health, int damage, int defense) {
super("Goblin",50,5,6);
this.name = name;
this.health = health;
this.damage = damage;
this.defense = defense;
}
}
public class WolfMonster extends Monster {
public WolfMonster(String name, int health, int damage, int defense) {
super("Wolf",50,5,6);
this.name = name;
this.health = health;
this.damage = damage;
this.defense = defense;
}
}
public class FightManager {
GameManager manage = new GameManager();
Player player = new Player("Player",100,10,5);
GoblinMonster gobli = new GoblinMonster("Goblin", 40, 7, 4);
WolfMonster wolf = new WolfMonster("Wolf",50,9,6);
boolean myTurn = true;
....
I want to know how to assign a value of monster depending on which monster is generated.