public final class MathExpression
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static java.util.List<java.lang.String> |
fixedFunctions |
Constructor and Description |
---|
MathExpression(MathExpression existing)
Creates a new mathematical expression that is a copy from another one
|
MathExpression(java.lang.String expression)
Creates a new mathematical expression from the string
|
Modifier and Type | Method and Description |
---|---|
MathExpression |
combine(char operator,
MathExpression... elements)
Combines the current expression with one or more other expressions and a
binary operator (such as +,* or -).
|
boolean |
equals(java.lang.Object o)
Returns true if the expressions are identical, false otherwise
|
double |
evaluate()
Evaluates the result of the expression
|
double |
evaluate(Assignment input)
Evaluates the result of the expression, given an assignment of values to the
unknown variables
|
java.util.Set<java.lang.String> |
getVariables()
Returns the unknown variable labels in the expression
|
int |
hashCode()
Returns the hashcode for the expression
|
java.lang.String |
toString()
Returns a string representation of the expression
|
public MathExpression(java.lang.String expression)
expression
- the expressionpublic MathExpression(MathExpression existing)
existing
- the expression to copypublic java.util.Set<java.lang.String> getVariables()
public double evaluate()
public double evaluate(Assignment input)
input
- the assignmentpublic MathExpression combine(char operator, MathExpression... elements)
operator
- the operator between the expressionelements
- the elements to addpublic java.lang.String toString()
toString
in class java.lang.Object
public boolean equals(java.lang.Object o)
equals
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object