home *** CD-ROM | disk | FTP | other *** search
/ Learn Java Now / Learn_Java_Now_Microsoft_1996.iso / JavaNow / Code / Chap09 / BankAccount / InsufficientFundsException.class (.txt) < prev    next >
Encoding:
Java Class File  |  1996-08-02  |  1.1 KB  |  22 lines

  1. public class InsufficientFundsException extends Exception {
  2.    private BankAccount m_ba;
  3.    private double m_dWithdrawalAmount;
  4.  
  5.    InsufficientFundsException(BankAccount ba, double dAmount) {
  6.       super("Insufficient funds in account ");
  7.       this.m_ba = ba;
  8.       this.m_dWithdrawalAmount = dAmount;
  9.    }
  10.  
  11.    public String toString() {
  12.       StringBuffer sb = new StringBuffer();
  13.       sb.append("Insufficient funds in account ");
  14.       sb.append(this.m_ba.Id());
  15.       sb.append("\nBalance was ");
  16.       sb.append(this.m_ba.Balance());
  17.       sb.append("\nWithdrawal was ");
  18.       sb.append(this.m_dWithdrawalAmount);
  19.       return sb.toString();
  20.    }
  21. }
  22.