我有一个由 Land 扩展的 SimpleBoard 类,然后由 Units 扩展。每当我尝试编译 Units 时,都会收到此错误:
cannot find symbol
symbol : constructor Land()
location: class Land
public Units(int x, int y){
想出了什么问题?
编辑:对不起,我很着急!这是完整的代码:
public class Units extends Land{
private int attack;
public Units(int x, int y) {
if(x==1){
attack = 1;
}
else if(x==2)
attack = 2;
else if(x==3)
attack = 4;
ar[y].AddUnit(this);
}
public int getAttack(){
return attack;
}
}
和土地
public class Land extends SimpleBoard {
private boolean barrel = false;
private boolean crown = false;
private boolean castle = false;
private boolean stronghold = false;
private int num;
private int array = 0;
public int[] adjacent;
private Units [] Occupy = new Units [4];
public Land(int z, int x, int c, int v, int b, int[] array){
if(z == 1)
barrel = true;
if(x == 1)
crown = true;
if(c == 1)
castle = true;
if (v==1)
stronghold = true;
num = b;
adjacent = array;
}
public void addUnit(Units x){
Occupy[array] = x;
array++;
}
public boolean checkB(){
return barrel;
}
public int getAdj(int i){
return adjacent[i];
}
}
和板
public class SimpleBoard {
public static Land[] ar = new Land[3];
public static void main(String[] args){
Land One = new Land(1,0,0,0,1, new int[]{2, 3});
Land Two = new Land(0,1,0,0,2, new int[]{1, 3});
Land Three = new Land(0,0,1,0,3, new int[]{1, 2});
ar[0] = One;
ar[1] = Two;
ar[2] = Three;
Units Footman = new Units(1, 1);
Units Knight = new Units(2, 3);
Units Siege = new Units(3, 2);
}
}