/*
 * BankAccount.java
 *
 * Created on January 30, 2005, 12:22 PM
 */

/**
 *
 * @author Bill Kraynek
 */
public class BankAccount implements Comparable<BankAccount> {
    private String id;
    private double balance;
    
    /** Creates a new instance of BankAccount
     * @param newId the id of the customer
     */
    public BankAccount(String newId) {
        id = newId;
    } // end constructor
    
    /** Gets the customer's id
     * @return the id as a String
     */ 
    public String getId() {
        return id;
    }// end getId
    
    /** Gets the customer's balance
     * @return the balance as a double
     */
    public double getBalance() {
        return balance;
    }// end balance
    
    /** Process a deposit
     * @param deposit the amount deposited
     */
    public void deposit(double deposit) {
        balance += deposit;
    }// end deposit
    
    /** Process a withdrawal
     * @param withdrawal the amount withdrawn
     */
    public void withdraw(double withdrawal) {
        balance -= withdrawal;
    }// end withdraw
    
    /** Check if BankAccounts are equal
     * @param a BankAccount object
     * @return true if id's match
     */    
    public boolean equals(Object rhs) {
        if( rhs == null ) return false;
        if( !getClass().equals(rhs.getClass()) ) return false;
        return id.equals(((BankAccount)rhs).getId());
    } // end equals
    
    public int hashCode() {
        return getId().hashCode();
    }
    
    public String toString() {
        return "[Name: " + id + ", Balance = " + balance + "]";
    } // end toString
    
    public int compareTo(BankAccount acct) {
        return id.compareTo(acct.id);
    }
    
}// end BankAccount

