

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.Weight
Weight
objects used to hold weight information. Objects
can only be instantiated using the WeightFormat
class.
A Weight
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 Weight
objects
will be printed using the overrided toString() method.
A set of arithmetic operations have been included to compare, add, subtract,
divide and multiply Weight
objects. Arithmetic operations have
been designed to be null
safe.
Field Summary  
protected static WeightUnits 
baseUnit

static Weight 
ZERO
Instance of Weight with zero value. 
Fields inherited from class com.pcauto.util.Quantity 
quantity, unit 
Constructor Summary  
protected 
Weight(double quantity,
WeightUnits unit)
Creates new Weight with an initial value
double value and WeightUnits unit. 
Method Summary  
Weight 
add(Weight quant)
Adds this Weight to the supplied
Weight . 
static Weight 
add(Weight a,
Weight b)
Adds supplied Weight to other supplied
Weight . 
static boolean 
areEqual(Weight quant1,
Weight quant2)
Determines if two Weight objects passed
to the fuction are equal. 
java.lang.Object 
clone()
Creates new Weight using an instance of Weight 
int 
compareTo(Weight quant)
Compares this Weight with the specified
Weight . 
Weight 
divide(java.math.BigDecimal divisor)
Divides this Weight by supplied
BigDecimal . 
java.math.BigDecimal 
divide(Weight quant)
Divides this Weight by supplied
Weight . 
boolean 
equals(Weight quant)
Compares this Weight to the specified
Weight . 
static WeightUnits 
getBaseUnit()
Gets base unit with which this weight is printed. 
boolean 
greaterThan(Weight quant)
Compares this Weight to the specified
Weight . 
boolean 
lessThan(Weight quant)
Compares this Weight to the specified
Weight . 
Weight 
multiply(java.math.BigDecimal multiplier)
Multiplies this Weight by supplied
BigDecimal . 
static void 
setBaseUnit(WeightUnits unit)
Sets the "toString" representation of any Weight objects
to be of type unit . 
Weight 
subtract(Weight quant)
Subtracts supplied Weight from
this Weight . 
java.lang.String 
toString()
Returns String representation of quantity of
Quantity object in baseUnit. 
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, wait, wait, wait 
Field Detail 
protected static WeightUnits baseUnit
public static final Weight ZERO
Weight
with zero value.
Constructor Detail 
protected Weight(double quantity, WeightUnits unit)
Weight
with an initial value
double
value and WeightUnits
unit.
quantity
 double
weightunit
 int
Method Detail 
public static void setBaseUnit(WeightUnits unit)
Weight
objects
to be of type unit
.
public static WeightUnits getBaseUnit()
this
weight is printed.
WeightUnits
unit with which weights are printed.public java.lang.Object clone()
Weight
using an instance of Weight
clone
in class Quantity
Quantity
objectpublic boolean equals(Weight quant)
this
Weight
to the specified
Weight
.
The result is true
if and only if the argument is not
null
and is a Weight
object that has
the same value.
Null
parameter returns false.
quant
 Weight
with which to compare
true
if weights are equivalent;
false
othewise.public int compareTo(Weight quant)
this
Weight
with the specified
Weight
. Null
parameter returns 1.
quant
 Weight
object with which to compare.
this
Weight
is larger.
1 if this
Weight
is smaller.public boolean greaterThan(Weight quant)
this
Weight
to the specified
Weight
.
quant
 Weight
object with which to compare.
true
if this
is greater
than quant
;
false
otherwisepublic boolean lessThan(Weight quant)
this
Weight
to the specified
Weight
.
quant
 Weight
object with which to compare.
true
if this
is less
than quant
; false
otherwisepublic static boolean areEqual(Weight quant1, Weight quant2)
Weight
objects passed
to the fuction are equal. Two null
are considered equal.
public Weight add(Weight quant)
this
Weight
to the supplied
Weight
.
Null
parameter is considered equal to Weight
with ZERO quantity.
quant
 Weight
object to add
Weight
object resulting from addition operationpublic static Weight add(Weight a, Weight b)
Weight
to other supplied
Weight
. Null
parameter(s) is considered
to be equal to ZERO quantity.
a
 first Weight
objectb
 second Weight
object
Weight
object resulting from addition of a
and b in Weight
a's unitpublic Weight subtract(Weight quant)
Weight
from
this
Weight
.
Null
parameter is considered equal to Weight
with zero quantity
quant
 Weight
object to subtract
Weight
object resulting from subtraction
operation in this
unitpublic java.math.BigDecimal divide(Weight quant)
this
Weight
by supplied
Weight
.
quant
 Weight
object to divide by
BigDecimal
object resulting from division operation
ArithmeticException
 on the attempt to divide by
null
or zeropublic Weight multiply(java.math.BigDecimal multiplier)
this
Weight
by supplied
BigDecimal
.
Weight
object resulting from multiplication operation
ArithmeticException
 on the attempt to
multiply by null
public Weight divide(java.math.BigDecimal divisor)
this
Weight
by supplied
BigDecimal
.
Weight
object resulting from division operation
ArithmeticException
 on the attempt
to divide by null
or zeropublic java.lang.String toString()
String
representation of quantity of
Quantity
object in baseUnit.
String


PREV CLASS NEXT CLASS  FRAMES NO FRAMES  
SUMMARY: NESTED  FIELD  CONSTR  METHOD  DETAIL: FIELD  CONSTR  METHOD 