/** class Sum, our internal representation of a sum-expression * in the L0 language. * See http://www.radford.edu/itec380/2008fall/Hw06/hw06.html * * @author Ian Barland * @version 2008.Nov.30 */ public class Sum extends Expr { static final String TOKEN = "+"; Expr e1, e2; Sum( Expr _e1, Expr _e2 ) { this.e1 = _e1; this.e2 = _e2; } public String toString() { return "(" + e1.toString() + " " + TOKEN + e2.toString() + ")"; } public Value eval() { return new Num( ((Num)(e1.eval())).doubleValue() + ((Num)(e2.eval())).doubleValue() ); } }