I am trying to extend a class to multiple other classes e.g.
public class Ability extends Character
Due to this i am getting an error in my code:
Implicit super constructor Character() is undefined. Must explicitly invoke another constructor Defense.java
My code is:
public class Character {
int characterID;
double characterHealth;
public Character(int charID, double charHealth) {
characterID = charID;
characterHealth = charHealth;
}
}
public class Defense extends Character {
int armorClass;
int difficultyClass;
public Defense(int newAC, int newDC){
armorClass = newAC;
difficultyClass = newDC;
}
}
I am unsure of how to invoke another constructor.
If someone could point out why and how to do it.
From a sub-class ctor:
Since the superclass has no default constructor you must explicitly call a non-default constructor.