hussam.math.operations
Class Variable
java.lang.Object
hussam.math.operations.Variable
- All Implemented Interfaces:
- Operation
- Direct Known Subclasses:
- Constant
public class Variable
- extends java.lang.Object
- implements Operation
A Variable is an operation indicating a variable amount. A Variable has a name indicating a key mapping for the operation it stores.
- Since:
- 2.0
- Author:
- Hussam Al-Mulhim حسام الملحم
- See Also:
Operation, ConstantNumber, Constant, Function
| Constructor Summary |
|---|
Variable(java.lang.String name) Construcs a New Variable given the name. |
| Method Summary |
|---|
java.lang.String | getName() Returns the name of the variable. |
double | result() returns the result of the operation. |
void | setOperation(Operation o) Sets the operation from which the result of this variable will be calculated. |
java.lang.String | toString() Returns the name of the variable. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Variable
public Variable(java.lang.String name)
- Construcs a New Variable given the name.
- Parameters:
name - The name of the variable.
getName
public java.lang.String getName()
- Returns the name of the variable.
- Returns:
- name of the Variable.
setOperation
public void setOperation(Operation o)
- Sets the operation from which the result of this variable will be calculated. For example, you can set this variable to a ConstantNumber using:
variable.setOperation(new ConstantNumber(50));
System.out.println(variable.result());
Output:
50.0
- Parameters:
o - The operation from which the result will be calculated.
result
public double result()
throws MathException- Description copied from interface:
Operation returns the result of the operation.
- Specified by:
result in interface Operation
- Returns:
- The result value.
- Throws:
MathException - Throws MathException if there is a Math Exception!!
toString
public java.lang.String toString()
- Returns the name of the variable.
- Overrides:
toString in class java.lang.Object
- Returns:
- the name of the variable.