/** * file : AccountData.java * desc : Implements a customer's account profile for the virtual * teller machine */ import HashTable.*; public class AccountData { /** * post : creates a new account for customer `newName' * with a $0 starting balance */ public AccountData( String newName ) { name = newName; balance = 0; } /** * post : returns the name of this account's owner */ public String getOwner() { return name; } /** * post : return the balance on this account */ public int getBalance() { return balance; } /** * post : reduces the balance by the withdrawl amount, amt */ public void withdraw( int amt ) { if( amt <= balance ) { balance -= amt; } else { System.out.println( "Error: Insufficient funds: " + amt ); } } /** * post : deposits `amt' into this account */ public void deposit( int amt ) { if( amt >= 0 ) { balance += amt; } else { System.out.println( "Error: Tried to deposit less than 0: " + amt ); } } private String name; // customer name private int balance; // starting balance } // eof