|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.pcauto.util.Quantity com.pcauto.util.Volume
Volume
objects used to hold volume information. Objects
Volume
can only be instantiated using the VolumeFormat
class. A Volume
object's concept of unit is hidden from class
users, and instead inferred from the formatter class at instantiation.
The baseUnit is used to store the unit with which Volume
objects will be printed using the overrided toString() method.
A set of arithmetic operations have been included to compare, add, subtract,
divide and multiply Volume
objects. Arithmetic operations
have been designed to be null
safe.
Field Summary | |
protected static VolumeUnits |
baseUnit
|
static Volume |
ZERO
Instance of Volume with zero value. |
Fields inherited from class com.pcauto.util.Quantity |
quantity, unit |
Constructor Summary | |
protected |
Volume(double quantity,
VolumeUnits unit)
Creates new Volume with an initial value double
value and VolumeUnits unit. |
Method Summary | |
Volume |
add(Volume quant)
Adds this Volume to the supplied
Volume . |
static Volume |
add(Volume a,
Volume b)
Adds supplied Volume to other supplied
Volume . |
static boolean |
areEqual(Volume quant1,
Volume quant2)
Determines if two Volume objects passed
to the fuction are equal. |
java.lang.Object |
clone()
Creates new Volume identical to this
Volume . |
int |
compareTo(Volume quant)
Compares this Volume with the specified
Volume . |
Volume |
divide(java.math.BigDecimal divisor)
Divides this Volume by supplied
BigDecimal . |
java.math.BigDecimal |
divide(Volume quant)
Divides this Volume by supplied
Volume . |
boolean |
equals(Volume quant)
Compares this Volume to the specified
Volume . |
static VolumeUnits |
getBaseUnit()
Gets base unit with which this volume is printed. |
boolean |
greaterThan(Volume quant)
Compares this Volume to the specified
Volume . |
boolean |
lessThan(Volume quant)
Compares this Volume to the specified
Volume . |
Volume |
multiply(java.math.BigDecimal multiplier)
Multiplies this Volume by supplied
BigDecimal . |
static void |
setBaseUnit(VolumeUnits unit)
Sets the "toString" representation of any Volume objects
to be of type unit . |
Volume |
subtract(Volume quant)
Subtracts supplied Volume from
this Volume . |
Methods inherited from class com.pcauto.util.Quantity |
add, add, areEqual, compareTo, compareTo, divide, equals, equals, getQuantity, getUnit, greaterThan, lessThan, myDivide, myMultiply, setQuantity, setUnit, setZERO, subtract |
Methods inherited from class java.lang.Object |
finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected static VolumeUnits baseUnit
public static final Volume ZERO
Volume
with zero value.
Constructor Detail |
protected Volume(double quantity, VolumeUnits unit)
Volume
with an initial value double
value and VolumeUnits
unit.
quantity
- double
volumeunit
- VolumeUnits
Method Detail |
public static VolumeUnits getBaseUnit()
this
volume is printed.
VolumeUnits
unit with which volumes are printed.public static void setBaseUnit(VolumeUnits unit)
Volume
objects
to be of type unit
.
public java.lang.Object clone()
Volume
identical to this
Volume
.
clone
in class Quantity
Volume
objectpublic boolean equals(Volume quant)
this
Volume
to the specified
Volume
.
The result is true
if and only if the argument is not
null
and is a Volume
object that has the same
value. Null
parameter returns false.
quant
- Volume
with which to compare
true
if Volumes are equivalent;
false
othewise.public int compareTo(Volume quant)
this
Volume
with the specified
Volume
. Null
parameter returns 1.
quant
- Volume
object with which to compare.
this
Volume
is
larger. -1 if this
Volume
is smaller.public boolean greaterThan(Volume quant)
this
Volume
to the specified
Volume
.
quant
- Volume
object with which to compare.
true
if this
is greater
than quant
;
false
otherwisepublic boolean lessThan(Volume quant)
this
Volume
to the specified
Volume
.
quant
- Volume
object with which to compare.
true
if this
is less
than quant
; false
otherwisepublic static boolean areEqual(Volume quant1, Volume quant2)
Volume
objects passed
to the fuction are equal. Two null
are considered equal.
public Volume add(Volume quant)
this
Volume
to the supplied
Volume
.
Null
parameter is considered equal to Volume
with ZERO quantity.
quant
- Volume
object to add
Volume
object resulting from addition operationpublic static Volume add(Volume a, Volume b)
Volume
to other supplied
Volume
. Null
parameter(s) is considered
to be equal to ZERO quantity.
a
- first Volume
objectb
- second Volume
object
Volume
object resulting from addition of a
and b in Volume
a's unitpublic Volume subtract(Volume quant)
Volume
from
this
Volume
.
Null
parameter is considered equal to Volume
with zero quantity
quant
- Volume
object to subtract
Volume
object resulting from subtraction
operation in this
unitpublic java.math.BigDecimal divide(Volume quant)
this
Volume
by supplied
Volume
.
quant
- Volume
object to divide by
BigDecimal
object resulting from division operation
ArithmeticException
- on the attempt
to divide by null
or zeropublic Volume multiply(java.math.BigDecimal multiplier)
this
Volume
by supplied
BigDecimal
.
Volume
object resulting from multiplication operation
ArithmeticException
- on the
attempt to multiply by null
public Volume divide(java.math.BigDecimal divisor)
this
Volume
by supplied
BigDecimal
.
Volume
object resulting from division operation
ArithmeticException
- on the attempt
to divide by null
or zero
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |