/////// File Account.java /////// /** * Superclass of bank account hierarchy. * @author Paul S. Wang */ public class Account // class name { public Account() {} /** * Constructor. Initializes a new account. * @param id Account number * @param amt Initial balance amount * @param ss Social security number as string */ public Account(int id, double amt, String ss) { acct_no = id; balance = amt; this.ss = ss; } /** * Retrieves the account balance. * @return the balance */ public double balance() { return(balance); } /** * Deposits into account. * @param amt the amount to deposit, if amt <=0 no effect */ public void deposit(double amt) { if ( amt > 0 ) balance += amt; } /** * Withdraw from account. * @param amt the amount to deposit * @return false if amt <=0 * or insufficient balance */ public boolean withdraw(double amt) { if( amt <= 0 || amt > balance ) return(false); // failure balance -= amt; return(true); } /* other public members */ public static boolean transfer (double amt, Account from, Account to) { boolean ok = from.withdraw(amt); if ( ok ) to.deposit(amt); return(ok); } /** * The account nubmer. */ protected int acct_no; // account number /** * The social security number of owner. */ protected String ss; // owner ss no. // private fields /** * The account balance. */ private double balance; // current balance }