类型“classname”的层次结构不一致——eclipse中的java错误

类型“classname”的层次结构不一致——eclipse中的java错误,java,eclipse,inheritance,extends,class-structure,Java,Eclipse,Inheritance,Extends,Class Structure,我有一个类CircleController,它扩展了一个类VehicleController,我不明白为什么会出现这个错误。任何帮助都将不胜感激 电路控制器是 车辆控制器类是 import javax.realtime.*; public class VehicleController extends RealtimeThread{ protected Simulator newSim; protected GroundVehicle newVehic; private double prev

我有一个类CircleController,它扩展了一个类VehicleController,我不明白为什么会出现这个错误。任何帮助都将不胜感激

电路控制器是

车辆控制器类是

import javax.realtime.*;
public class VehicleController  extends RealtimeThread{
protected Simulator newSim;
protected GroundVehicle newVehic;
private double prevTime;
private int numSides;
public double turnDuration;
public double edgeTravelDuration;
public boolean isTurning = false;
public boolean controllerInitialized=false;
public double timeOfManoeuverStart;
protected static int numControllers=0;
protected int controllerID = 0;
private static double avoidWallDist = 15;
private static double timeUpdateInterval = .1;

//constants
private final int diameter=50;

public VehicleController(Simulator s, GroundVehicle v){
    //error if input is incorrect
    if (s==null)
        throw new IllegalArgumentException("error, a null Simulator was inputted.");
    if (v==null)
        throw new IllegalArgumentException("error, a null Ground Vehicle was inputted.");
    this.newSim=s;
    this.newVehic=v;
    setNumSides(5);
    synchronized(VehicleController.class){
        controllerID=numControllers;
        numControllers++;
    }
}

public VehicleController(Simulator s, GroundVehicle v, SchedulingParameters schedule, ReleaseParameters release){
    //error if input is incorrect
    if (s==null)
        throw new IllegalArgumentException("error, a null Simulator was inputted.");
    if (v==null)
        throw new IllegalArgumentException("error, a null Ground Vehicle was inputted.");
    this.newSim=s;
    this.newVehic=v;
    setNumSides(5);
    synchronized(VehicleController.class){
        controllerID=numControllers;
        numControllers++;
    }
}

private void initializeController(){
    /* The bulk of this method is to determine how long to spend turning at
     * each corner of the polygon, and how long to spend driving along each
     * edge. We calculate turnDuration and edgeTravelDuration, and then use
     * these inside getControl to decide when to switch from turning to
     * travelling straight and back again. */ 

    double interiorAngle = (Math.PI/180)*(180+180*(numSides-3))/numSides;
    double turningAngle = Math.PI - interiorAngle;
    double minTurningRadius = newSim.minTransSpeed/newSim.maxRotSpeed;      //  v/w=r
    double arcLength = (turningAngle)*minTurningRadius; //need to know at what point we need to start turning
    turnDuration = arcLength/newSim.minTransSpeed; //shortest length needed to make this turn
    double edgeLength = diameter*Math.cos(interiorAngle/2) -(2*minTurningRadius*Math.tan((turningAngle)/2));
    edgeTravelDuration =edgeLength/newSim.maxTransSpeed;
    isTurning=true; //meaning we are done with the straightaway and need to turn.
    timeOfManoeuverStart = -turnDuration/2.0;
    controllerInitialized=true;
}

public Control getControl(int sec, int msec) {
    double controlTime = sec+msec*1E-3;

    Control c = null;

    if (isTurning) {
        if (controlTime - timeOfManoeuverStart < turnDuration)
         c = new Control(newSim.minTransSpeed, newSim.maxRotSpeed);
        else {
          isTurning = false;
          timeOfManoeuverStart = controlTime;
          c = new Control(newSim.maxTransSpeed, 0);
      } 
    } 
    else {
        if (controlTime - timeOfManoeuverStart < edgeTravelDuration)
        c = new Control(newSim.maxTransSpeed, 0);
        else {
                isTurning = true;
                timeOfManoeuverStart = controlTime;
                c = new Control(newSim.minTransSpeed, newSim.maxRotSpeed);
        } 
    }
    return c;
}

public void setNumSides(int n){
    if (n>10 || n<3)
        numSides=numSides;
    else
        numSides=n;
    initializeController();
}

public int getNumSides(){
    return numSides;
}

public void run(){
    int sec=0, mSec=0;
    double currentTime=0;
    //prevTime=0;
    // The simulation time is called by multiple threads, so we must put it in a simulator block.
    double prevTime=0;
    while (currentTime<100){
            synchronized(newSim){
                sec = newSim.getCurrentSec();
                mSec = newSim.getCurrentMSec();
                currentTime =sec+mSec/1000.0;
                if (currentTime>prevTime+ timeUpdateInterval){
                    prevTime = currentTime;
                    Control c =getControl(sec,mSec);
                    if (c!=null){
                        newVehic.controlVehicle(c);
                    }
                }
                newSim.notifyAll();
            }
    }
}
protected Control avoidWalls(double[] pos) {
    if (pos[0] > 100 - avoidWallDist && pos[1] > 100 - avoidWallDist) {
        if (pos[2] > -3 * Math.PI / 4.0) {
        return new Control(5, -Math.PI/4);
        } else {
        return new Control(5, Math.PI/4);
        }
    }

    if (pos[0] > 100 - avoidWallDist && pos[1] < 0 + avoidWallDist) {
        if (pos[2] > 3 * Math.PI / 4.0) {
        return new Control(5, -Math.PI/4);
        } else {
        return new Control(5, Math.PI/4);
        }
    }

    if (pos[0] < 0 + avoidWallDist && pos[1] > 100 - avoidWallDist) {
        if (pos[2] > -Math.PI / 4.0) {
        return new Control(5, -Math.PI/4);
        } else {
        return new Control(5, Math.PI/4);
        }
    }

    if (pos[0] < 0 + avoidWallDist && pos[1] < 0 + avoidWallDist) {
        if (pos[2] > Math.PI / 4.0) {
        return new Control(5, -Math.PI/4);
        } else {
        return new Control(5, Math.PI/4);
        }
    }

    if (pos[0] > 100 - avoidWallDist) {
        if (pos[2] > 0) {
        return new Control(5, Math.PI/4);
        } else {
        return new Control(5, -Math.PI/4);
        }
    }
    if (pos[0] < 0 + avoidWallDist) {
        if (pos[2] > 0) {
        return new Control(5, -Math.PI/4);
        } else {
        return new Control(5, Math.PI/4);
        }
    }

    if (pos[1] < 0 + avoidWallDist) {
        if (pos[2] > Math.PI / 2) {
        return new Control(5, -Math.PI/4);
        } else {
        return new Control(5, Math.PI/4);
        }
    }

    if (pos[1] > 100- avoidWallDist) {
        if (pos[2] > -Math.PI / 2) {
        return new Control(5, -Math.PI/4);
        } else {
        return new Control(5, Math.PI/4);
        }
    }
    return null;
    }

}

你能粘贴完整的错误信息吗?通常是缺少一些间接依赖项jar,这是我在eclipse中看到的错误消息,在这行旁边。VehicleController类不依赖于任何jar文件。
import javax.realtime.*;
public class VehicleController  extends RealtimeThread{
protected Simulator newSim;
protected GroundVehicle newVehic;
private double prevTime;
private int numSides;
public double turnDuration;
public double edgeTravelDuration;
public boolean isTurning = false;
public boolean controllerInitialized=false;
public double timeOfManoeuverStart;
protected static int numControllers=0;
protected int controllerID = 0;
private static double avoidWallDist = 15;
private static double timeUpdateInterval = .1;

//constants
private final int diameter=50;

public VehicleController(Simulator s, GroundVehicle v){
    //error if input is incorrect
    if (s==null)
        throw new IllegalArgumentException("error, a null Simulator was inputted.");
    if (v==null)
        throw new IllegalArgumentException("error, a null Ground Vehicle was inputted.");
    this.newSim=s;
    this.newVehic=v;
    setNumSides(5);
    synchronized(VehicleController.class){
        controllerID=numControllers;
        numControllers++;
    }
}

public VehicleController(Simulator s, GroundVehicle v, SchedulingParameters schedule, ReleaseParameters release){
    //error if input is incorrect
    if (s==null)
        throw new IllegalArgumentException("error, a null Simulator was inputted.");
    if (v==null)
        throw new IllegalArgumentException("error, a null Ground Vehicle was inputted.");
    this.newSim=s;
    this.newVehic=v;
    setNumSides(5);
    synchronized(VehicleController.class){
        controllerID=numControllers;
        numControllers++;
    }
}

private void initializeController(){
    /* The bulk of this method is to determine how long to spend turning at
     * each corner of the polygon, and how long to spend driving along each
     * edge. We calculate turnDuration and edgeTravelDuration, and then use
     * these inside getControl to decide when to switch from turning to
     * travelling straight and back again. */ 

    double interiorAngle = (Math.PI/180)*(180+180*(numSides-3))/numSides;
    double turningAngle = Math.PI - interiorAngle;
    double minTurningRadius = newSim.minTransSpeed/newSim.maxRotSpeed;      //  v/w=r
    double arcLength = (turningAngle)*minTurningRadius; //need to know at what point we need to start turning
    turnDuration = arcLength/newSim.minTransSpeed; //shortest length needed to make this turn
    double edgeLength = diameter*Math.cos(interiorAngle/2) -(2*minTurningRadius*Math.tan((turningAngle)/2));
    edgeTravelDuration =edgeLength/newSim.maxTransSpeed;
    isTurning=true; //meaning we are done with the straightaway and need to turn.
    timeOfManoeuverStart = -turnDuration/2.0;
    controllerInitialized=true;
}

public Control getControl(int sec, int msec) {
    double controlTime = sec+msec*1E-3;

    Control c = null;

    if (isTurning) {
        if (controlTime - timeOfManoeuverStart < turnDuration)
         c = new Control(newSim.minTransSpeed, newSim.maxRotSpeed);
        else {
          isTurning = false;
          timeOfManoeuverStart = controlTime;
          c = new Control(newSim.maxTransSpeed, 0);
      } 
    } 
    else {
        if (controlTime - timeOfManoeuverStart < edgeTravelDuration)
        c = new Control(newSim.maxTransSpeed, 0);
        else {
                isTurning = true;
                timeOfManoeuverStart = controlTime;
                c = new Control(newSim.minTransSpeed, newSim.maxRotSpeed);
        } 
    }
    return c;
}

public void setNumSides(int n){
    if (n>10 || n<3)
        numSides=numSides;
    else
        numSides=n;
    initializeController();
}

public int getNumSides(){
    return numSides;
}

public void run(){
    int sec=0, mSec=0;
    double currentTime=0;
    //prevTime=0;
    // The simulation time is called by multiple threads, so we must put it in a simulator block.
    double prevTime=0;
    while (currentTime<100){
            synchronized(newSim){
                sec = newSim.getCurrentSec();
                mSec = newSim.getCurrentMSec();
                currentTime =sec+mSec/1000.0;
                if (currentTime>prevTime+ timeUpdateInterval){
                    prevTime = currentTime;
                    Control c =getControl(sec,mSec);
                    if (c!=null){
                        newVehic.controlVehicle(c);
                    }
                }
                newSim.notifyAll();
            }
    }
}
protected Control avoidWalls(double[] pos) {
    if (pos[0] > 100 - avoidWallDist && pos[1] > 100 - avoidWallDist) {
        if (pos[2] > -3 * Math.PI / 4.0) {
        return new Control(5, -Math.PI/4);
        } else {
        return new Control(5, Math.PI/4);
        }
    }

    if (pos[0] > 100 - avoidWallDist && pos[1] < 0 + avoidWallDist) {
        if (pos[2] > 3 * Math.PI / 4.0) {
        return new Control(5, -Math.PI/4);
        } else {
        return new Control(5, Math.PI/4);
        }
    }

    if (pos[0] < 0 + avoidWallDist && pos[1] > 100 - avoidWallDist) {
        if (pos[2] > -Math.PI / 4.0) {
        return new Control(5, -Math.PI/4);
        } else {
        return new Control(5, Math.PI/4);
        }
    }

    if (pos[0] < 0 + avoidWallDist && pos[1] < 0 + avoidWallDist) {
        if (pos[2] > Math.PI / 4.0) {
        return new Control(5, -Math.PI/4);
        } else {
        return new Control(5, Math.PI/4);
        }
    }

    if (pos[0] > 100 - avoidWallDist) {
        if (pos[2] > 0) {
        return new Control(5, Math.PI/4);
        } else {
        return new Control(5, -Math.PI/4);
        }
    }
    if (pos[0] < 0 + avoidWallDist) {
        if (pos[2] > 0) {
        return new Control(5, -Math.PI/4);
        } else {
        return new Control(5, Math.PI/4);
        }
    }

    if (pos[1] < 0 + avoidWallDist) {
        if (pos[2] > Math.PI / 2) {
        return new Control(5, -Math.PI/4);
        } else {
        return new Control(5, Math.PI/4);
        }
    }

    if (pos[1] > 100- avoidWallDist) {
        if (pos[2] > -Math.PI / 2) {
        return new Control(5, -Math.PI/4);
        } else {
        return new Control(5, Math.PI/4);
        }
    }
    return null;
    }

}