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

/// <summary> 
///   A specialization of BankAccount.
/// </summary>
public class LotteryAccount: BankAccount {

   private static Lottery lottery  = Lottery.Instance(20);

   /// <summary> Construct a lottery account based on 
   ///   owner o and the initial balance b </summary>
   /// <param name = "o"> The owner of the account </param>
   /// <param name = "b"> The initial balance of the account </param>
   public LotteryAccount(string o, decimal b): 
     base(o, b, 0.0) {
   }

   /// <summary> Add interest to the lottery account.
   ///    This may be a lot if a drawn lottery number is
   ///    the winning number. If not, zero interest is added.
   /// </summary>
   public override void AddInterests() {
      int luckyNumber = lottery.DrawLotteryNumber;
      balance = balance + lottery.AmountWon(luckyNumber);
   }    

   /// <summary>
   ///   Return a text string that represents this account
   ///   for output purposes
   /// </summary>
   public override string ToString() {
      return owner + "'s lottery account holds " +
            + balance + " kroner";
   }
}