All Packages  Class Hierarchy  This Package  Previous  Next  Index
  Class banking.Money
java.lang.Object
   |
   +----banking.Money
  -  public class Money
  -  extends Object
Representation for money amounts
   
  -   cents cents
-  Instance variable: this amount represented as a number of cents 
   
  -   Money(int) Money(int)
-  Constructor
  
  
-   Money(int, int) Money(int, int)
-  Constructor
  
  
-   Money(Money) Money(Money)
-  Copy constructor
  
   
  -   add(Money) add(Money)
-  Add an amount of money to this
  
  
-   lessEqual(Money) lessEqual(Money)
-  Compare this to another amount
  
  
-   subtract(Money) subtract(Money)
-  Subtract an amount of money from this
  
  
-   toString() toString()
-  Create a string representation of this amount
  
   
 cents
cents
 private long cents
  -  Instance variable: this amount represented as a number of cents
 
   
 Money
Money
 public Money(int dollars)
  -  Constructor
   
- 
    -  Parameters:
    
-  dollars - whole dollar amount
  
 
 Money
Money
 public Money(int dollars,
              int cents)
  -  Constructor
   
- 
    -  Parameters:
    
-  dollars - dollar part of amount
    -  cents - cents part of amount
  
 
 Money
Money
 public Money(Money toCopy)
  -  Copy constructor
   
- 
    -  Parameters:
    
-  toCopy - the Money object to copy
  
 
   
 toString
toString
 public String toString()
  -  Create a string representation of this amount
   
- 
    -  Returns:
    
-  string representation of this amount
    
-  Overrides:
    
-  toString in class Object
  
 
 add
add
 public void add(Money amountToAdd)
  -  Add an amount of money to this
   
- 
    -  Parameters:
    
-  amountToAdd - the amount to add
  
 
 subtract
subtract
 public void subtract(Money amountToSubtract)
  -  Subtract an amount of money from this
   
- 
    -  Parameters:
    
-  amountToSubtract - the amount to subtract
  Precondition: amount must be <= this amount
  
 
 lessEqual
lessEqual
 public boolean lessEqual(Money compareTo)
  -  Compare this to another amount
   
- 
    -  Parameters:
    
-  compareTo - the amount to compare to
    
-  Returns:
    
-  true if this amount is <= compareTo amount
  
 
All Packages  Class Hierarchy  This Package  Previous  Next  Index