Package uk.co.cogitolearning.cogpar
Class ConstantExpressionNode
- java.lang.Object
-
- uk.co.cogitolearning.cogpar.ConstantExpressionNode
-
- All Implemented Interfaces:
ExpressionNode
public class ConstantExpressionNode extends Object implements ExpressionNode
An ExpressionNode that stores a constant value
-
-
Field Summary
-
Fields inherited from interface uk.co.cogitolearning.cogpar.ExpressionNode
ADDITION_NODE, CONSTANT_NODE, EXPONENTIATION_NODE, FUNCTION_NODE, MULTIPLICATION_NODE, VARIABLE_NODE
-
-
Constructor Summary
Constructors Constructor Description ConstantExpressionNode(double value)Construct with the fixed value.ConstantExpressionNode(String value)Convenience constructor that takes a string and converts it to a double before storing the value.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaccept(ExpressionNodeVisitor visitor)Implementation of the visitor design pattern.intgetType()Returns the type of the node, in this case ExpressionNode.CONSTANT_NODEdoublegetValue()Returns the value of the constant
-
-
-
Constructor Detail
-
ConstantExpressionNode
public ConstantExpressionNode(double value)
Construct with the fixed value.- Parameters:
value- the value of the constant
-
ConstantExpressionNode
public ConstantExpressionNode(String value)
Convenience constructor that takes a string and converts it to a double before storing the value.- Parameters:
value- the string representation of the value
-
-
Method Detail
-
getValue
public double getValue()
Returns the value of the constant- Specified by:
getValuein interfaceExpressionNode- Returns:
- value of expression
-
getType
public int getType()
Returns the type of the node, in this case ExpressionNode.CONSTANT_NODE- Specified by:
getTypein interfaceExpressionNode- Returns:
- type of the node
-
accept
public void accept(ExpressionNodeVisitor visitor)
Implementation of the visitor design pattern. Calls visit on the visitor.- Specified by:
acceptin interfaceExpressionNode- Parameters:
visitor- the visitor
-
-