|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.pcauto.util.Quantity
com.pcauto.util.Temperature
Temperature objects used to hold temperature information.
Objects can only be instantiated using the TemperatureFormat class.
A Temperature 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 Temperature
objects will be printed using the overrided toString() method.
A set of arithmetic operations have been included to compare, add, subtract,
divide and multiply currency objects. Arithmetic operations have been
designed to be null safe.
| Field Summary | |
protected static TemperatureUnits |
baseUnit
|
static Temperature |
ZERO
Instance of Temperature with zero value. |
| Fields inherited from class com.pcauto.util.Quantity |
quantity, unit |
| Constructor Summary | |
protected |
Temperature(double quantity,
TemperatureUnits unit)
Creates new Temperature with an initial value
double value and int unit. |
| Method Summary | |
Temperature |
add(Temperature quant)
Adds this Temperature to the supplied
Temperature. |
static Temperature |
add(Temperature a,
Temperature b)
Adds supplied Temperature to other supplied
Temperature. |
static boolean |
areEqual(Temperature quant1,
Temperature quant2)
Determines if two Temperature objects passed
to the fuction are equal. |
java.lang.Object |
clone()
Creates new Temperature identical to this
Temperature |
int |
compareTo(Temperature quant)
Compares this Temperature with the specified
Temperature. |
Temperature |
divide(java.math.BigDecimal divisor)
Divides this Temperature by supplied
BigDecimal. |
java.math.BigDecimal |
divide(Temperature quant)
Divides this Temperature by supplied
Temperature. |
boolean |
equals(Temperature quant)
Compares this Temperature to the specified
Temperature. |
static TemperatureUnits |
getBaseUnit()
Gets base unit with this temperature is printed. |
boolean |
greaterThan(Temperature quant)
Compares this Temperature to the specified
Temperature. |
boolean |
lessThan(Temperature quant)
Compares this Temperature to the specified
Temperature. |
Temperature |
multiply(java.math.BigDecimal multiplier)
Multiplies this Temperature by supplied
BigDecimal. |
static void |
setBaseUnit(TemperatureUnits unit)
Sets the "toString" representation of any Temperature objects
to be of type unit. |
Temperature |
subtract(Temperature quant)
Subtracts supplied Temperature from
this Temperature. |
| 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 TemperatureUnits baseUnit
public static final Temperature ZERO
Temperature with zero value.
| Constructor Detail |
protected Temperature(double quantity,
TemperatureUnits unit)
Temperature with an initial value
double value and int unit.
quantity - double temperatureunit - TemperatureUnits| Method Detail |
public static TemperatureUnits getBaseUnit()
this temperature is printed.
TemperatureUnits unit with which temperatures are stored.public static void setBaseUnit(TemperatureUnits unit)
Temperature objects
to be of type unit.
public java.lang.Object clone()
Temperature identical to this
Temperature
clone in class QuantityTemperature objectpublic boolean equals(Temperature quant)
this Temperature to the specified
Temperature.
The result is true if and only if the argument is not
null and is a Temperature object that
has the same value. Null parameter returns false.
quant - Temperature with which to compare
true if Currencies are equivalent;
false othewise.public int compareTo(Temperature quant)
this Temperature with the specified
Temperature. Null parameter returns 1.
quant - Temperature object with which to compare.
this
Temperature is larger.
-1 if this Temperature is smaller.public boolean greaterThan(Temperature quant)
this Temperature to the specified
Temperature.
quant - Temperature object with which to compare.
true if this is greater
than quant;
false otherwisepublic boolean lessThan(Temperature quant)
this Temperature to the specified
Temperature.
quant - Temperature object with which to compare.
true if this is less
than quant; false otherwise
public static boolean areEqual(Temperature quant1,
Temperature quant2)
Temperature objects passed
to the fuction are equal. Two null are considered equal.
public Temperature add(Temperature quant)
this Temperature to the supplied
Temperature.
Null parameter is considered equal to
Temperature with ZERO quantity.
quant - Temperature object to add
Temperature object resulting from addition operation
public static Temperature add(Temperature a,
Temperature b)
Temperature to other supplied
Temperature. Null parameter(s) is
considered to be equal to ZERO quantity.
a - first Temperature objectb - second Temperature object
Temperature object resulting from addition of a
and b in Temperature a's unitpublic Temperature subtract(Temperature quant)
Temperature from
this Temperature.
Null parameter is considered equal to
Temperature with zero quantity
quant - Temperature object to subtract
Temperature object resulting from subtraction
operation in this unitpublic java.math.BigDecimal divide(Temperature quant)
this Temperature by supplied
Temperature.
quant - Temperature object to divide by
BigDecimal object resulting from division operation
ArithmeticException - on the attempt
to divide by null or zeropublic Temperature multiply(java.math.BigDecimal multiplier)
this Temperature by supplied
BigDecimal.
Temperature object resulting
from multiplication operation
ArithmeticException - on the attempt
to multiply by nullpublic Temperature divide(java.math.BigDecimal divisor)
this Temperature by supplied
BigDecimal.
Temperature 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 | ||||||||