我正在尝试将一个类扩展到多个其他类,例如
public class Ability extends Character
因此,我的代码中出现错误:
隐式超级构造函数 Character() 未定义。必须显式调用另一个构造函数 Defense.java
我的代码是:
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;
}
}
我不确定如何调用另一个构造函数。如果有人可以指出为什么以及如何做到这一点。