Package uk.co.cogitolearning.cogpar
Interface ExpressionNode
-
- All Known Implementing Classes:
AdditionExpressionNode,ConstantExpressionNode,ExponentiationExpressionNode,FunctionExpressionNode,MultiplicationExpressionNode,SequenceExpressionNode,VariableExpressionNode
public interface ExpressionNodeAn interface for expression nodes. Every concrete type of expression node has to implement this interface.
-
-
Field Summary
Fields Modifier and Type Field Description static intADDITION_NODENode id for addition nodesstatic intCONSTANT_NODENode id for constant nodesstatic intEXPONENTIATION_NODENode id for exponentiation nodesstatic intFUNCTION_NODENode id for function nodesstatic intMULTIPLICATION_NODENode id for multiplication nodesstatic intVARIABLE_NODENode id for variable nodes
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description voidaccept(ExpressionNodeVisitor visitor)Method needed for the visitor design patternintgetType()Returns the type of the node.ExpressionNode Each class derived from ExpressionNode representing a specific role in the expression should return the type according to that role.doublegetValue()Calculates and returns the value of the sub-expression represented by the node.
-
-
-
Field Detail
-
VARIABLE_NODE
static final int VARIABLE_NODE
Node id for variable nodes- See Also:
- Constant Field Values
-
CONSTANT_NODE
static final int CONSTANT_NODE
Node id for constant nodes- See Also:
- Constant Field Values
-
ADDITION_NODE
static final int ADDITION_NODE
Node id for addition nodes- See Also:
- Constant Field Values
-
MULTIPLICATION_NODE
static final int MULTIPLICATION_NODE
Node id for multiplication nodes- See Also:
- Constant Field Values
-
EXPONENTIATION_NODE
static final int EXPONENTIATION_NODE
Node id for exponentiation nodes- See Also:
- Constant Field Values
-
FUNCTION_NODE
static final int FUNCTION_NODE
Node id for function nodes- See Also:
- Constant Field Values
-
-
Method Detail
-
getType
int getType()
Returns the type of the node.ExpressionNode Each class derived from ExpressionNode representing a specific role in the expression should return the type according to that role.- Returns:
- type of the node
-
getValue
double getValue()
Calculates and returns the value of the sub-expression represented by the node.- Returns:
- value of expression
-
accept
void accept(ExpressionNodeVisitor visitor)
Method needed for the visitor design pattern- Parameters:
visitor- the visitor
-
-