public class TreeNodeFactory
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
private static char |
ADDITION_SYMBOL |
private static char |
MULTIPLICATION_SYMBOL |
private static char |
SUBTRACTION_SYMBOL |
Constructor and Description |
---|
TreeNodeFactory() |
Modifier and Type | Method and Description |
---|---|
static Constant |
createConstant(int value)
Creates a Constant node.
|
static ArithmeticOperation |
createOperation(char type,
Tree leftOperand,
Tree rightOperand)
Create a concrete arithmetic operation.
|
static Variable |
createVariable(java.lang.String name)
Creates a Variable node.
|
private static final char MULTIPLICATION_SYMBOL
private static final char SUBTRACTION_SYMBOL
private static final char ADDITION_SYMBOL
public static Constant createConstant(int value)
value
- the constant integer valuepublic static Variable createVariable(java.lang.String name)
name
- the name of the variablepublic static ArithmeticOperation createOperation(char type, Tree leftOperand, Tree rightOperand) throws java.lang.IllegalArgumentException
type
- the operation type, that can '+', '-' or '*'.leftOperand
- the left sub-tree as left operand of the operationrightOperand
- the right sub-tree as right operandjava.lang.IllegalArgumentException
- if an unknown type (char) is asked, this exception will occur