hussam.math.operations
Class ConstantNumber

java.lang.Object
extended by hussam.math.operations.ConstantNumber
All Implemented Interfaces:
Operation, java.io.Serializable, java.lang.Cloneable

public final class ConstantNumber
extends java.lang.Object
implements Operation

هذه الفئة تمثل رقما عمليا مثل: 4و 5و 40و -123,345345. الفئة في السابق كانت تسمى Number This resembles a Constant Number like 4 , 3000, 5234, or -1234.23452. The old Version of the class was called Number. I changed it to ConstantNumber so that you dont need to use the full name of the class to distinguish between it and java.lang.Number.

Version:
2.0
Author:
Hussam AlMulhim حسام الملحم
See Also:
Variable, Function, Serialized Form

Field Summary
protected  doublenumber
          The double value.
 
Constructor Summary
ConstantNumber(double x)
          Constructs a Constant Number.
 
Method Summary
 ConstantNumberclone(OperatorSourceImpl s)
          This method clones the operation.
 ConstantNumberoptimize()
          This method optimizes the operation.
 doubleresult()
          returns the result of the operation.
 java.lang.StringtoString()
          Returns the double value stored in this ConstantNumber.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

number

protected double number
The double value.

Constructor Detail

ConstantNumber

public ConstantNumber(double x)
Constructs a Constant Number.

Parameters:
x - the double value for the ConstantNumber to represent. the result method would reutrn this value.
Method Detail

result

public double result()
Description copied from interface: Operation
returns the result of the operation.

Specified by:
result in interface Operation
Returns:
The result value.

toString

public java.lang.String toString()
Returns the double value stored in this ConstantNumber.

Overrides:
toString in class java.lang.Object
Returns:
The double value.

clone

public ConstantNumber clone(OperatorSourceImpl s)
Description copied from interface: Operation
This method clones the operation. Cloning can be achieved by useing the default clone method since Operations are Clonable since Version 3! However, cloning sometimes needs more than what the clone method offers! Notice that this clone method takes an OperatorSource as a parameter, this method should update this source with any arguments needed such as Variables! It can be seen as an implemetation of the Visitor approach. It is also worth to note that this method's implemetation is optional. You can egnore the implemetation of this method and just return
this
.

Specified by:
clone in interface Operation
Parameters:
s - The OperatorSourceImpl.
Returns:
Returns the cloned operation.
See Also:
clone(hussam.math.operations.dataBase.OperatorSourceImpl), Variable.clone(hussam.math.operations.dataBase.OperatorSourceImpl)

optimize

public ConstantNumber optimize()
Description copied from interface: Operation
This method optimizes the operation. Optimization can increase compile time and decrease run time execution. This method should generate an operation that generate the same result(). This method is one of the main methods intruduced in Version 3 of the HussamMathParser package. It is also worth to note that this methods' implementation is optional! you can just return
this
.

Specified by:
optimize in interface Operation
Returns:
an optimized Operation of this operation.