public class Length
extends java.lang.Object
Constructor and Description |
---|
Length(double value) |
Modifier and Type | Method and Description |
---|---|
Length |
add(Length length)
Adds 2 length objects.
|
int |
compareTo(java.lang.Object that)
Compares this quantity with the given object.
|
double |
getValue()
Returns the numerical value in the current unit as a double
|
Length |
subtract(Length length)
Subtracts 2 length objects.
|
java.lang.String |
toString()
Returns a string representation of this length
|
java.lang.String |
toString(int floats)
Returns a string representation of the quantity with at most
floats decimals.
|
public double getValue()
public Length add(Length length)
length
- the Length object to be added to this lengthpublic Length subtract(Length length)
length
- the Length object to be subtracted from this lengthpublic java.lang.String toString(int floats)
public java.lang.String toString()
toString
in class java.lang.Object
public int compareTo(java.lang.Object that)
that
is
of type Quantity the comparison results in: -1 : if this < that 0 : if
this == that 1 : if this > thatjava.lang.ClassCastException
- if that
is not a Quantity object