我一直在研究一个用 RaspberryPi 3B+ 控制 LED 矩阵的程序,我想构建我的程序,以便每个矩阵都是 MatrixComponents 的数组。
package matrixcontroller;
public class MatrixComponent throws Exception{
private String componentMode; // Defines whether component is an input or output device.
private String controlType; // For recalling whether component is analog, binary, or PWM.
public MatrixComponent(String componentMode, String controlType) {
if (componentMode.toUpperCase().equals("INPUT")) this.componentMode = "INPUT";
else if (componentMode.toUpperCase().equals("OUTPUT")) this.componentMode = "OUTPUT";
else throw new InvalidComponentModeException("'" + componentMode + "' is not a valid component mode.");
}
}
到目前为止,这是我开始研究的内容,但我的 IDE (Netbeans) 告诉我 InvalidComponentModeException 不是一个类。问题是我在同一个包中有一个 InvalidComponentModeException 类,所以我对它为什么不起作用感到困惑。有任何想法吗?
package matrixcontroller;
public class InvalidComponentModeException extends RuntimeException {
public InvalidComponentModeException(){
super();
}
public InvalidComponentModeException(String message){
super(message);
}
}