|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objecthelper.Piggybank
public class Piggybank
This class encapsulates a piggy bank that can hold quarters and nickels (no other coins). It provides a limited variety of services, such as adding to and modifying the piggy bank.
Constructor Summary | |
---|---|
Piggybank()
Constructs a default piggy bank with the value of quarters as 0 and the number of nickels as 0. |
Method Summary | |
---|---|
void |
addOneNickel()
Add one nickel to the piggy bank |
void |
addOneQuarters()
Add one quarter to the piggy bank |
boolean |
equals(java.lang.Object otherPiggybank)
Checks whether this piggy bank is equal to the passed piggy bank |
int |
getNickels()
Returns the number of nickels in the piggy bank |
int |
getQuarters()
Returns the number of quarters in the piggy bank |
int |
getTotalValueOfPiggybank()
|
int |
getValueOfNickels()
Returns the value of the nickels in the piggybank in cents |
int |
getValueOfQuarters()
Returns the value of the quarters in the piggybank in cents |
boolean |
hasSameValue(Piggybank otherPiggybank)
Checks whether the value of the piggy bank is equal to the passed piggy bank |
void |
setNickels(int nickels)
Sets the number of nickels in this piggybank to be the passed quantity. |
void |
setQuarters(int quarters)
Sets the number of quarters in this piggybank to be the passed quantity. |
void |
shouldShowValue(boolean shouldShowValue)
Sets whether this object, when printed out using its toProperString() method, shows itself as a monetary value or as a formatted string that lists the contents of this piggybank. |
java.lang.String |
toProperString()
Returns a string representation of this Piggy Bank that is either its monetary value or a formatted description of the contents of this piggybank (in terms of the number of quarters and nickels contained in this piggy bank). |
Methods inherited from class java.lang.Object |
---|
getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public Piggybank()
Method Detail |
---|
public void addOneNickel()
public void addOneQuarters()
public int getQuarters()
public void setQuarters(int quarters)
quarters
- the number of quarters that should be in this piggybank
java.lang.Exception
- if the number of quarters is less than zeriopublic int getNickels()
public void setNickels(int nickels)
nickels
- the number of nickels that should be in this piggybank
java.lang.Exception
- if the number of nickels is less than zeriopublic int getValueOfNickels()
public int getValueOfQuarters()
public int getTotalValueOfPiggybank()
public boolean equals(java.lang.Object otherPiggybank)
equals
in class java.lang.Object
public boolean hasSameValue(Piggybank otherPiggybank)
public void shouldShowValue(boolean shouldShowValue)
public java.lang.String toProperString()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |