我的代码有问题,主类有String n,int s,int d,int i
public class Maincharacter {
static Dice dice = new Dice();
private final String name;
private final int strength;
private final int dexterity;
public int intelligence;
public Maincharacter(String n, int s, int d, int i){
this.name = n;
this.strength = s;
this.dexterity = d;
this.intelligence = i;
}
我需要使3个扩展类获得相同的属性,但它们之间存在差异
public class Mage extends Maincharacter {
static Dice dice = new Dice();
private int maxMagic;
public int currentMagic;
private int heal;
public Mage(String n, int s, int d){
super (n,s,d);
this.maxMagic = 100;
this.currentMagic = maxMagic;
}
我只想获得String n,int s和int d,但错误说它的长度不同,我还需要添加int i。
很抱歉,如果有一些混乱,或者它可能含糊不清,但我不知道如何编码那么多。
你已经过去了
超(n,s,d);
但是超类构造函数要求4个参数,所以你应该将4个参数传递给Mage类构造函数
super(n,s,d,/ *另一个参数应该传递* /);