Back to notes -- Keyboard shortcut: 'u'  previous -- Keyboard shortcut: 'p'  next -- Keyboard shortcut: 'n'  Slide program -- Keyboard shortcut: 't'    Adding interests without use of dynamic binding - AddInterest is not virtual.Lecture 7 - slide 36 : 40
Program 2
using System;

public class AccountClient{

  public static void Main(){
     BankAccount[] accounts = 
      new BankAccount[5]{
        new CheckAccount("Per",1000.0M, 0.03),
        new SavingsAccount("Poul",1000.0M, 0.03),
        new CheckAccount("Kurt",1000.0M, 0.03),
        new LotteryAccount("Bent",1000.0M),
        new LotteryAccount("Lone",1000.0M)
      };

    foreach(BankAccount ba in accounts){
      if (ba is CheckAccount)
        ((CheckAccount)ba).AddInterests();  
      else if (ba is SavingsAccount)
        ((SavingsAccount)ba).AddInterests();  
      else if (ba is LotteryAccount)
        ((LotteryAccount)ba).AddInterests();  
      else if (ba is BankAccount)
        ((BankAccount)ba).AddInterests();  
    }  

    foreach(BankAccount ba in accounts){
      Console.WriteLine("{0}", ba);
    }
  }

}