|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectmae.tut.num.Number
The abstract superclass of all numbers: Whole, Rational, Decimal, Complex, Matrix.
Subclasses of Number must provide methods to add, multiply by another Number, find the multiplicative inverse, and give the float value.
Number objects are immutable: constructed once, never modified.
V1.0 Jan 12, 2002 Mutable objects V1.1 Jan 26, 2002 exp() generalized V2.0 Jun 30, 2003 NetBeans implementation: immutable V2.1 Dec 30, 2003 Factory class redesigned -> Cruncher
| Method Summary | |
abstract Number |
add(Number n)
Adds this Number to another Number n and returns the result. |
int |
hashCode()
hashCode that would be returned by a Float object with the same value. |
abstract Number |
inverse()
Returns the multiplicative inverse of this Number. |
abstract Number |
mult(Number n)
Multiplies this Number by another Number n and returns the result. |
abstract float |
value()
Returns the float value of this Number. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, notify, notifyAll, toString, wait, wait, wait |
| Method Detail |
public abstract Number add(Number n)
If this Number and n are of the same type, returned result
must be of that type.
If this and n are of different types, returned result
must be as narrow as possible.
But in all cases add(n)
and n.add(this) must return the same Number.
public abstract Number mult(Number n)
If this Number and n are of the same type, returned result
must be of that type.
If this and n are of different types, returned result
must be as narrow as possible.
But in all cases mult(n)
and n.mult(this) must return the same Number.
public abstract Number inverse()
For any Number n, if inverse() is defined,
n.inverse().inverse() must be equal to n.
Also n.inverse().mult(n).value() must be 1.0
public abstract float value()
public int hashCode()
Equal Numbers have the same value, thus the same hashCode.
Needed by subclasses that redefine equals(Object)
Ordinal.equals(Object),
Complex.equals(Object)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||