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

public class LotteryAccount: BankAccount {

   // Instance variables of BankAccount are inherited

   protected static Lottery lottery  = Lottery.Instance(3);

   public LotteryAccount(string o, decimal b): 
     base(o, b, 0.0) {
   }

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

   public override void AddInterests() {
      int luckyNumber = lottery.DrawLotteryNumber;
      balance = balance + lottery.AmountWon(luckyNumber);
   }    

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