An ExpressionNode that handles additions and subtractions. More...


Public Member Functions | |
| AdditionExpressionNode () | |
| Default constructor. | |
| AdditionExpressionNode (ExpressionNode node, boolean positive) | |
| Constructor to create an addition with the first term already added. | |
| int | getType () |
| Returns the type of the node, in this case ExpressionNode.ADDITION_NODE. | |
| double | getValue () |
| Returns the value of the sub-expression that is rooted at this node. | |
| void | accept (ExpressionNodeVisitor visitor) |
| Implementation of the visitor design pattern. | |
Public Member Functions inherited from uk.co.cogitolearning.cogpar.SequenceExpressionNode | |
| SequenceExpressionNode () | |
| Default constructor. | |
| SequenceExpressionNode (ExpressionNode a, boolean positive) | |
| Constructor to create a sequence with the first term already added. | |
| void | add (ExpressionNode node, boolean positive) |
| Add another term to the sequence. | |
Additional Inherited Members | |
Static Public Attributes inherited from uk.co.cogitolearning.cogpar.ExpressionNode | |
| static final int | VARIABLE_NODE = 1 |
| Node id for variable nodes. | |
| static final int | CONSTANT_NODE = 2 |
| Node id for constant nodes. | |
| static final int | ADDITION_NODE = 3 |
| Node id for addition nodes. | |
| static final int | MULTIPLICATION_NODE = 4 |
| Node id for multiplication nodes. | |
| static final int | EXPONENTIATION_NODE = 5 |
| Node id for exponentiation nodes. | |
| static final int | FUNCTION_NODE = 6 |
| Node id for function nodes. | |
Protected Attributes inherited from uk.co.cogitolearning.cogpar.SequenceExpressionNode | |
| ArrayList< Term > | terms |
| the list of terms in the sequence | |
An ExpressionNode that handles additions and subtractions.
The node can hold an arbitrary number of terms that are either added or subtraced from the sum.
Definition at line 32 of file AdditionExpressionNode.java.
| uk.co.cogitolearning.cogpar.AdditionExpressionNode.AdditionExpressionNode | ( | ExpressionNode | node, |
| boolean | positive | ||
| ) |
Constructor to create an addition with the first term already added.
| node | the term to be added |
| positive | a flag indicating whether the term is added or subtracted |
Definition at line 49 of file AdditionExpressionNode.java.
| void uk.co.cogitolearning.cogpar.AdditionExpressionNode.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 all the terms in the sum.
| visitor | the visitor |
Implements uk.co.cogitolearning.cogpar.ExpressionNode.
Definition at line 89 of file AdditionExpressionNode.java.
| double uk.co.cogitolearning.cogpar.AdditionExpressionNode.getValue | ( | ) |
Returns the value of the sub-expression that is rooted at this node.
All the terms are evaluated and added or subtracted from the total sum.
Implements uk.co.cogitolearning.cogpar.ExpressionNode.
Definition at line 67 of file AdditionExpressionNode.java.
1.8.1.2