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

  1. class BankAccount {
  2.    double m_dCurrentInterestRate;
  3.    double m_dBalance;
  4.  
  5.    void Withdrawal(double dAmount) {
  6.       if (dAmount >= (double)0.0F && dAmount <= this.m_dBalance) {
  7.          this.m_dBalance -= dAmount;
  8.       }
  9.  
  10.    }
  11.  
  12.    void Interest() {
  13.       this.m_dBalance += this.m_dBalance * (this.m_dCurrentInterestRate / (double)1200.0F);
  14.    }
  15.  
  16.    void Monthly() {
  17.       this.Fee();
  18.       this.Interest();
  19.    }
  20.  
  21.    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 void SetRate(double dNewRate) {
  27.       if (dNewRate > (double)0.0F && dNewRate < (double)20.0F) {
  28.          this.m_dCurrentInterestRate = dNewRate;
  29.       }
  30.  
  31.    }
  32.  
  33.    void Deposit(double dAmount) {
  34.       if (dAmount > (double)0.0F) {
  35.          this.m_dBalance += dAmount;
  36.       }
  37.  
  38.    }
  39.  
  40.    void Fee() {
  41.       this.m_dBalance -= (double)5.0F;
  42.    }
  43.  
  44.    public double CurrentRate() {
  45.       return this.m_dCurrentInterestRate;
  46.    }
  47. }
  48.