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

  1. public 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.    public void Monthly() {
  17.       this.Fee();
  18.       this.Interest();
  19.    }
  20.  
  21.    public double Balance() {
  22.       int nCents = (int)(this.m_dBalance * (double)100.0F + (double)0.5F);
  23.       return (double)nCents / (double)100.0F;
  24.    }
  25.  
  26.    public static double Rate() {
  27.       return m_dCurrentInterestRate;
  28.    }
  29.  
  30.    public static void Rate(double dNewRate) {
  31.       if (dNewRate > (double)0.0F && dNewRate < (double)20.0F) {
  32.          m_dCurrentInterestRate = dNewRate;
  33.       }
  34.  
  35.    }
  36.  
  37.    public void Deposit(double dAmount) {
  38.       if (dAmount > (double)0.0F) {
  39.          this.m_dBalance += dAmount;
  40.       }
  41.  
  42.    }
  43.  
  44.    public void Fee() {
  45.       this.m_dBalance -= (double)5.0F;
  46.    }
  47. }
  48.