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
 
Method Summary
 CurrencyAsLong add(CurrencyAsLong x)
           
 byte getCents()
           
 long getDollars()
           
 boolean getSign()
           
 CurrencyAsLong increment(CurrencyAsLong x)
           
static void main(java.lang.String[] args)
          test program
 void setCents(byte theCents)
          set cents = theCents throws IllegalArgumentException when theCents < 0 or theCents > 99
 void setDollars(long theDollars)
          set dollars = theDollars
 void setSign(boolean theSign)
          Set the sign of amount to theSign.
 void setValue(CurrencyAsLong x)
           
 void setValue(double theValue)
          set amount
 java.lang.String toString()
          convert to a string
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

PLUS

public static final boolean PLUS

MINUS

public static final boolean MINUS
Constructor Detail

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
Method Detail

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