Package uk.co.cogitolearning.cogpar
Class FunctionExpressionNode
- java.lang.Object
-
- uk.co.cogitolearning.cogpar.FunctionExpressionNode
-
- All Implemented Interfaces:
ExpressionNode
public class FunctionExpressionNode extends Object implements ExpressionNode
An ExpressionNode that handles mathematical functions. Some pre-defined functions are handled, others can easily be added.
-
-
Field Summary
-
Fields inherited from interface uk.co.cogitolearning.cogpar.ExpressionNode
ADDITION_NODE, CONSTANT_NODE, EXPONENTIATION_NODE, FUNCTION_NODE, MULTIPLICATION_NODE, VARIABLE_NODE
-
-
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.FUNCTION_NODEdoublegetValue()Returns the value of the sub-expression that is rooted at this node.
-
-
-
Method Detail
-
getType
public int getType()
Returns the type of the node, in this case ExpressionNode.FUNCTION_NODE- Specified by:
getTypein interfaceExpressionNode- Returns:
- type of the node
-
getValue
public double getValue()
Returns the value of the sub-expression that is rooted at this node. The argument is evaluated and then the function is applied to the resulting value.- Specified by:
getValuein interfaceExpressionNode- Returns:
- value of expression
-
accept
public void accept(ExpressionNodeVisitor visitor)
Implementation of the visitor design pattern. Calls visit on the visitor and then passes the visitor on to the accept method of the argument.- Specified by:
acceptin interfaceExpressionNode- Parameters:
visitor- the visitor
-
-