|
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object
|
+--Money
Money represents an amount of dollars and cents.
Field Summary | |
static int |
CENTS
The number of cents in a dollar. |
Constructor Summary | |
Money()
Creates a new amount of Money with 0 dollars and 0 cents. |
|
Money(int dollars)
Creates a new amount of Money with the given amount of dollars and 0 cents. |
|
Money(int dollars,
int cents)
Creates a new amount of Money with the given amount of dollars and cents. |
Method Summary | |
void |
addMoney(Money amount)
Adds the given amount of Money to this amount of Money. |
int |
getCents()
Returns the number of cents in this amount of Money. |
int |
getDollars()
Returns the number of dollars in this amount of Money. |
boolean |
isEqual(Money amount)
Determines if this amount of Money is equal to the given amount of Money. |
boolean |
isGreater(Money amount)
Determines if this amount of Money is greater than the given amount of Money. |
java.lang.String |
toString()
Returns a String which represents the amount of dollars and cents in this amount of Money. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify,
notifyAll, wait, wait, wait |
Field Detail |
public static final int CENTS
Constructor Detail |
public Money()
public Money(int dollars)
dollars
- if positive, the number of dollars;
otherwise, 0public Money(int dollars,
int cents)
dollars
- if positive, the number of dollars;
otherwise, 0cents
- if between 0 and CENTS, the number of cents;
otherwise, 0Method Detail |
public java.lang.String toString()
toString
in class java.lang.Object
public int getDollars()
public int getCents()
public void addMoney(Money amount)
amount
- the amount of Money to addpublic boolean isEqual(Money amount)
amount
- the amount of Money to compare with
public boolean isGreater(Money amount)
amount
- the amount of Money to compare with
|
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |