CogPar
A versatile parser for mathematical expressions.
 All Classes Functions Variables
Public Member Functions | List of all members
uk.co.cogitolearning.cogpar.AdditionExpressionNode Class Reference

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

Inheritance diagram for uk.co.cogitolearning.cogpar.AdditionExpressionNode:
Inheritance graph
[legend]
Collaboration diagram for uk.co.cogitolearning.cogpar.AdditionExpressionNode:
Collaboration graph
[legend]

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< Termterms
 the list of terms in the sequence

Detailed Description

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.

Constructor & Destructor Documentation

uk.co.cogitolearning.cogpar.AdditionExpressionNode.AdditionExpressionNode ( ExpressionNode  node,
boolean  positive 
)

Constructor to create an addition with the first term already added.

Parameters
nodethe term to be added
positivea flag indicating whether the term is added or subtracted

Definition at line 49 of file AdditionExpressionNode.java.

Member Function Documentation

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.

Parameters
visitorthe 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.


The documentation for this class was generated from the following file: