Log in

View Full Version : "cannot be resolved as a type" Error


dex
10-02-2012, 13:29
We are working on making our switch to turn on and off our shooter system, a toggle and are getting an error.


package us.oh.k12.wkw.robot.command;

public class ToggleMotorStateCmd extends CommandBase {
public ToggleMotorStateCmd(){
super("ShooterTurnMotorOffCmd");
this.requires(this.getShooterSystem());
}

protected void execute() {
if (!this.getShooterSystem().isShootMotorOn()) {
// motor is off, turn it on
this.getShooterSystem().turnOnShootMotor();
} else{
//motor is on, turn it off
this.getShooterSystem().turnOffShootMotor();
}
}
}


In a lot of our other commands we extend CommandBase just fine, but this one is saying "CommandBase cannot be resolved as a type." Let me know if you need more information. Below is the method header of a time when we extend command base and it works.

package us.oh.k12.wkw.robot.command;
public class GathererTurnOnCmd extends CommandBase{
//code
}

Patrick Chiang
10-02-2012, 15:29
"X cannot be resolved as a type" errors are commonly caused by two reasons:
1. Missing import statement, wrong package.
2. Referring to a type that doesn't exist.

If you are using an IDE, there should be a way to automatically remedy this.

Also, doesn't Java make your implement all the methods of the abstract class?
protected void execute() {
}

protected boolean isFinished() {
}

protected void end() {
}

protected void interrupted() {
}