我正在为代数程序编写代码来操纵方程式。我有Expression接口的代码,并且已正确编译。我也有Variable类的代码,它无法编译并为Expression接口引发“错误:找不到符号”。它们在同一文件夹中(在“ SymbolicExpressions”文件夹中,该文件夹本身在“代数”文件夹中)。我不明白怎么了。也许我的环境变量设置不正确。您能提供的任何帮助将不胜感激。这是接口和类的代码:
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
/**
*
* @author zach
*/
public interface Expression extends Cloneable {
abstract public Expression evaluate(Expression v, Expression e);
abstract public Expression clone();
abstract public Expression fullSimplify();
abstract public Expression simpleSimplify();
}
import java.util.ArrayList;
import Algebra.SymbolicExpressions.Expression;
import java.lang.Character;
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
/**
*
* @author zach
*/
public class Variable implements Expression, Comparable<Variable>, Cloneable {
private char name;
private ArrayList<Expression> subscripts;
//Must implement infrastructure for subscripts, derivative superscripts. Potential implementation: earlier subscripts rank a higher order on the variable than later superscripts. In other words earlier subscripts decide variable's implementation of comparable before later subscripts. Superscript derivatives give higher priority based on the highest priority derivative's lowest order. Hopefully that makes sense the next time this comment is read
public Variable(char myName, ArrayList<Expression> subscriptInputs) {
name = myName;
for (Expression e: subscriptInputs) {
subscripts.add(e);
}
}
public Expression evaluate(Expression v, Expression e) {
if (this.compareTo(v)) {
return e;
}
return this;
}
@Override
public int hashCode() {
return Character.valueOf(name).hashCode();
}
public Expression fullSimplify() {
return this.clone(); //To change body of generated methods, choose Tools | Templates.
}
public Expression simpleSimplify() {
return this.clone(); //To change body of generated methods, choose Tools | Templates.
}
public int compareTo(Variable toCompare) {
return this.hashCode() - toCompare.hashCode();
}
public Expression clone() {
return new Variable(this.name, this.subscripts);
}
}