/////////////////////////////////////////////////////// // EquationComponent.java // // Written By Geoff Knagge (9806135) // last modified 14/8/1999 // // Defines a "component" of a mathematical expression. // this is either an operator, or a number. The codes // used for the various operators are left up to the // implementing class to decide upon... /////////////////////////////////////////////////////// public class EquationComponent { private boolean operator; private double value; ////////////////////// Constructors public EquationComponent(boolean op,double val) // specifying initial values... { operator = op; value = val; } public EquationComponent(double val) // specifying value, assuming not an operator { this(false,val); } public EquationComponent() // assuming a non operator with inital value 0. { this(false,0); } ////////////////////// Mutator Methods public void setValue(double val) // sets the value of the operand, or the code of the operator { value = val; } public void setOperator(boolean op) // set whether the component is an operator (op=TRUE) or // an operand (op=FALSE) { operator = op; } /////////////////////// Accessor Methods public boolean isOperator() // determine if the component is an operator (returns TRUE) // or an operand (returns FALSE) { return operator; } public double getValue() // returns the value of the operand, or the code of the operator { return value; } }