// COBOL Programmers Swing With Java - copyright 2005 Doke, Hardgrave, & Johnson // Chapter 5 - Computation // Program to model the CheckingAccount class // CheckingAccount.java 1 JAN 05 public class CheckingAccount extends Account // superclass is account { // attribute definition private float minimumBalance; // private scope limited to this class // constructor method public CheckingAccount(int newAccountNumber,float newCurrentBalance) { // invoke account constructor to populate account attributes super (newAccountNumber, newCurrentBalance); minimumBalance = newCurrentBalance; // populate attribute } // end constructor // accessor method public float getMinimumBalance () { return minimumBalance; } // instance method to post a check to this account public void recordACheck (float checkAmount) throws NSFException { float balance = getCurrentBalance(); if (balance >= checkAmount) // see if sufficient funds { balance = currentBalance - checkAmount; setCurrentBalance(balance); // store new balance } else {// if not, throw an exception NSFException e = new NSFException("Not Sufficient Funds"); throw e; } // end if } // end method recordACheck // post a deposit to this account public void recordADeposit (float depositAmount) { float balance = getCurrentBalance(); // retrieve balance balance = balance + depositAmount; // add deposit setCurrentBalance(balance); // store new balance } // end recordADeposit } // end of checking account class