home *** CD-ROM | disk | FTP | other *** search
/ Learn Java Now / Learn_Java_Now_Microsoft_1996.iso / JavaNow / Code / Chap07 / BankAccount / BankAccount.class (.txt) < prev    next >
Encoding:
Java Class File  |  1996-07-29  |  1.3 KB  |  54 lines

  1. public abstract class BankAccount {
  2.    private static double m_dCurrentInterestRate;
  3.    private double m_dBalance;
  4.  
  5.    public void Withdrawal(double dAmount) {
  6.       if (dAmount >= (double)0.0F && dAmount <= this.m_dBalance) {
  7.          this.m_dBalance -= dAmount;
  8.       }
  9.  
  10.    }
  11.  
  12.    public void Interest() {
  13.       this.m_dBalance += this.m_dBalance * (m_dCurrentInterestRate / (double)1200.0F);
  14.    }
  15.  
  16.    BankAccount(double dInitialBalance) {
  17.       this.m_dBalance = dInitialBalance;
  18.    }
  19.  
  20.    public abstract int AccountNo();
  21.  
  22.    public void Monthly() {
  23.       this.Fee();
  24.       this.Interest();
  25.    }
  26.  
  27.    public double Balance() {
  28.       int nCents = (int)(this.m_dBalance * (double)100.0F + (double)0.5F);
  29.       return (double)nCents / (double)100.0F;
  30.    }
  31.  
  32.    public static double Rate() {
  33.       return m_dCurrentInterestRate;
  34.    }
  35.  
  36.    public static void Rate(double dNewRate) {
  37.       if (dNewRate > (double)0.0F && dNewRate < (double)20.0F) {
  38.          m_dCurrentInterestRate = dNewRate;
  39.       }
  40.  
  41.    }
  42.  
  43.    public void Deposit(double dAmount) {
  44.       if (dAmount > (double)0.0F) {
  45.          this.m_dBalance += dAmount;
  46.       }
  47.  
  48.    }
  49.  
  50.    public void Fee() {
  51.       this.m_dBalance -= (double)5.0F;
  52.    }
  53. }
  54.