Back to notes -- Keyboard shortcut: 'u'  previous -- Keyboard shortcut: 'p'  next -- Keyboard shortcut: 'n'  Slide program -- Keyboard shortcut: 't'    The class SavingsAccount.Lecture 7 - slide 29 : 40
Program 3
using System;

public class SavingsAccount: BankAccount {

   // Instance variables of BankAccount are inherited

   public SavingsAccount(string o, double ir): 
     base(o, 0.0M, ir) {
   }

   public SavingsAccount(string o, decimal b, double ir): 
     base(o, b, ir) {
   }

   // Method Balance is inherited
   // Method Deposit is inherited

   public override void Withdraw (decimal amount) {
      if (amount < balance)
          base.Withdraw(amount);
      else
          throw new Exception("Cannot withdraw");
   }

   public override void AddInterests() {
      balance = balance + balance * (decimal)interestRate 
                        - 100.0M;
   }    

   public override string ToString() {
      return owner + "'s check account holds " +
            + balance + " kroner";
   }
}