public class Const extends java.lang.Number implements Arithmetic, java.lang.Comparable
| Constructor and Description | 
|---|
| Const()Creates a new Const with default 0 value | 
| Const(double num)Creates a new real Const for double input. | 
| Const(double r,
     double i)Creates a new complex Const for double input. | 
| Const(java.lang.Number number)Creates a new complex Const from a number input. | 
| Const(java.lang.String str)Creates a new Const from the specified string, which should be of the format "1.0", or "1.0 + 1.0i" for complex
 numbers. | 
| Modifier and Type | Method and Description | 
|---|---|
| Arithmetic | add(java.lang.Object obj)Adds this object and the given number | 
| int | compareTo(java.lang.Object num)Compares this object with the specified object for order. | 
| Arithmetic | divide(java.lang.Object obj)Divides this object by the given object | 
| double | doubleValue()Returns the value of the specified number as a  double. | 
| boolean | equals(java.lang.Object num)Returns true if the specified Object has the same value as the Const (the Object must be an instance of
 number). | 
| float | floatValue()Returns the value of the specified number as a  float. | 
| double | getImag() | 
| double | getReal() | 
| int | intValue()Returns the value of the specified number as an  int. | 
| boolean | isCompatible(java.lang.Object obj)Tests that the given object is a Const. | 
| boolean | isComplex() | 
| long | longValue()Returns the value of the specified number as a  long. | 
| Arithmetic | multiply(java.lang.Object obj)Multiplies this objectand the give number | 
| void | setComplex(double r,
          double i)Set the real part and imaginary parts to the given double inputs. | 
| void | setImag(double i)Set the imaginary part to the given double. | 
| void | setReal(double r)Set the real part to the given double. | 
| Arithmetic | subtract(java.lang.Object obj)Subtracts the number from this object | 
| java.lang.String | toString() | 
public Const()
public Const(double num)
num - the double value.public Const(java.lang.Number number)
number - the number value.public Const(java.lang.String str)
      throws java.lang.NumberFormatException
str - the const stringjava.lang.NumberFormatExceptionpublic Const(double r,
     double i)
r - the real double value.i - the imaginary double value.public boolean isComplex()
public double getReal()
public double getImag()
public void setReal(double r)
public void setImag(double i)
public void setComplex(double r,
              double i)
public boolean isCompatible(java.lang.Object obj)
isCompatible in interface Arithmeticobj - The data object to be compared with the current onepublic boolean equals(java.lang.Object num)
equals in interface Arithmeticequals in class java.lang.Objectnum - The object to be testedpublic int compareTo(java.lang.Object num)
compareTo in interface java.lang.Comparablepublic Arithmetic add(java.lang.Object obj) throws java.lang.ClassCastException
add in interface Arithmeticobj - the object containing the number for the arithmeticjava.lang.ClassCastException - if addition with the specified object is not validpublic Arithmetic subtract(java.lang.Object obj) throws java.lang.ClassCastException
subtract in interface Arithmeticobj - the object containing the number for the arithmeticjava.lang.ClassCastException - if subtraction with the specified object is not validpublic Arithmetic multiply(java.lang.Object obj) throws java.lang.ClassCastException
multiply in interface Arithmeticobj - the object containing the number for the arithmeticjava.lang.ClassCastException - if multiplication with the specified object is not validpublic Arithmetic divide(java.lang.Object obj) throws java.lang.ClassCastException
divide in interface Arithmeticobj - the object containing the number for the arithmeticjava.lang.ClassCastException - if division with the specified object is not validpublic int intValue()
int. This may involve rounding or truncation.intValue in class java.lang.Numberint.public long longValue()
long. This may involve rounding or truncation.longValue in class java.lang.Numberlong.public float floatValue()
float. This may involve rounding.floatValue in class java.lang.Numberfloat.public double doubleValue()
double. This may involve rounding.doubleValue in class java.lang.Numberdouble.public java.lang.String toString()
toString in class java.lang.Object