applications
Class Currency

java.lang.Object
  |
  +--applications.Currency

public class Currency
extends java.lang.Object


Field Summary
static boolean MINUS
           
static boolean PLUS
           
 
Constructor Summary
Currency()
          initialize instance to $0.00
Currency(boolean theSign, long theDollars, byte theCents)
          initialize instance to theSign $ theDollars.theCents
Currency(double theValue)
          initialize with double
 
Method Summary
 Currency add(Currency x)
           
 byte getCents()
           
 long getDollars()
           
 boolean getSign()
           
 Currency increment(Currency x)
           
static void main(java.lang.String[] args)
          test program
 void setCents(byte theCents)
          set cents = theCents
 void setDollars(long theDollars)
          set dollars = theDollars
 void setSign(boolean theSign)
          set sign = theSign
 void setValue(Currency x)
           
 void setValue(double theValue)
          set sign, dollars, and cents
 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

Currency

public Currency(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

Currency

public Currency()
initialize instance to $0.00

Currency

public Currency(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 sign = theSign

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:
java.lang.IllegalArgumentException - when theCents < 0 or > 99

setValue

public void setValue(double theValue)
set sign, dollars, and cents

setValue

public void setValue(Currency x)

toString

public java.lang.String toString()
convert to a string
Overrides:
toString in class java.lang.Object

add

public Currency add(Currency x)
Returns:
this + x

increment

public Currency increment(Currency x)
Returns:
this incremented by x

main

public static void main(java.lang.String[] args)
test program