// --------------------------------------------------------------- // VariableNode - Return the value associate with our name or // throw an exception if our name isn't found // --------------------------------------------------------------- import java.util.HashMap; public class VariableNode extends Node { public VariableNode(String name) { mName = name; } public double evaluate(HashMap env) throws Exception { Double theValue = env.get(mName); if(theValue == null) throw new Exception("Undefined variable: " + mName); return(theValue.doubleValue()); } public String toString() { return(mName); } private String mName; }