applications
Class CurrencyAsLong
java.lang.Object
|
+--applications.CurrencyAsLong
- public class CurrencyAsLong
- extends java.lang.Object
Field Summary |
static boolean |
MINUS
|
static boolean |
PLUS
|
Constructor Summary |
CurrencyAsLong()
initialize instance to $0.00 |
CurrencyAsLong(boolean theSign,
long theDollars,
byte theCents)
initialize instance to
theSign $ theDollars.theCents |
CurrencyAsLong(double theValue)
initialize with double |
Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
wait,
wait,
wait |
PLUS
public static final boolean PLUS
MINUS
public static final boolean MINUS
CurrencyAsLong
public CurrencyAsLong(boolean theSign,
long theDollars,
byte theCents)
- initialize instance to
theSign $ theDollars.theCents
- Throws:
- java.lang.IllegalArgumentException - when theDollars < 0
or theCents < 0 or theCents > 99
CurrencyAsLong
public CurrencyAsLong()
- initialize instance to $0.00
CurrencyAsLong
public CurrencyAsLong(double theValue)
- initialize with double
getSign
public boolean getSign()
- Returns:
- sign
getDollars
public long getDollars()
- Returns:
- dollars
getCents
public byte getCents()
- Returns:
- cents
setSign
public void setSign(boolean theSign)
- Set the sign of amount to theSign.
For this to work properly amount must be nonzero.
setDollars
public void setDollars(long theDollars)
- set dollars = theDollars
- Throws:
- java.lang.IllegalArgumentException - when theDollars < 0
setCents
public void setCents(byte theCents)
- set cents = theCents
throws IllegalArgumentException when theCents < 0 or theCents > 99
setValue
public void setValue(double theValue)
- set amount
setValue
public void setValue(CurrencyAsLong x)
toString
public java.lang.String toString()
- convert to a string
- Overrides:
- toString in class java.lang.Object
add
public CurrencyAsLong add(CurrencyAsLong x)
- Returns:
- this + x
increment
public CurrencyAsLong increment(CurrencyAsLong x)
- Returns:
- this incremented by x
main
public static void main(java.lang.String[] args)
- test program