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

An ExpressionNode that handles multiplications and divisions. More...

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

Public Member Functions

 MultiplicationExpressionNode ()
 Default constructor.
 MultiplicationExpressionNode (ExpressionNode a, boolean positive)
 Constructor to create a multiplication with the first term already added.
int getType ()
 Returns the type of the node, in this case ExpressionNode.MULTIPLICATION_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 multiplications and divisions.

The node can hold an arbitrary number of factors that are either multiplied or divided to the product.

Definition at line 32 of file MultiplicationExpressionNode.java.

Constructor & Destructor Documentation

uk.co.cogitolearning.cogpar.MultiplicationExpressionNode.MultiplicationExpressionNode ( ExpressionNode  a,
boolean  positive 
)

Constructor to create a multiplication with the first term already added.

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

Definition at line 48 of file MultiplicationExpressionNode.java.

Member Function Documentation

void uk.co.cogitolearning.cogpar.MultiplicationExpressionNode.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 product.

Parameters
visitorthe visitor

Implements uk.co.cogitolearning.cogpar.ExpressionNode.

Definition at line 88 of file MultiplicationExpressionNode.java.

double uk.co.cogitolearning.cogpar.MultiplicationExpressionNode.getValue ( )

Returns the value of the sub-expression that is rooted at this node.

All the terms are evaluated and multiplied or divided to the product.

Implements uk.co.cogitolearning.cogpar.ExpressionNode.

Definition at line 66 of file MultiplicationExpressionNode.java.


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