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
   -  Instance variable: this amount represented as a number of cents 
 
  
  -  
	Money(int)
   -  Constructor
  
  
 -  
	Money(int, int)
   -  Constructor
  
  
 -  
	Money(Money)
   -  Copy constructor
  
 
  
  -  
	add(Money)
   -  Add an amount of money to this
  
  
 -  
	lessEqual(Money)
   -  Compare this to another amount
  
  
 -  
	subtract(Money)
   -  Subtract an amount of money from this
  
  
 -  
	toString()
   -  Create a string representation of this amount
  
 
  
cents
 private long cents
  -  Instance variable: this amount represented as a number of cents
 
  
Money
 public Money(int dollars)
  -  Constructor
  
    -  Parameters:
    
 -  dollars - whole dollar amount
  
 
 
 
Money
 public Money(int dollars,
              int cents)
  -  Constructor
  
    -  Parameters:
    
 -  dollars - dollar part of amount
    
-  cents - cents part of amount
  
  
 
 
Money
 public Money(Money toCopy)
  -  Copy constructor
  
    -  Parameters:
    
 -  toCopy - the Money object to copy
  
 
 
 
  
toString
 public String toString()
  -  Create a string representation of this amount
  
    -  Returns:
    
 -  string representation of this amount
    
 -  Overrides:
    
 -  toString in class Object
  
 
 
 
add
 public void add(Money amountToAdd)
  -  Add an amount of money to this
  
    -  Parameters:
    
 -  amountToAdd - the amount to add
  
 
 
 
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
 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