Back to slide -- Keyboard shortcut: 'u'  previous -- Keyboard shortcut: 'p'  next -- Keyboard shortcut: 'n'          interface-documentation/bank-account-inheritance/check-account.cs - The class CheckAccount.Lecture 15 - slide 10 : 13
Program 2

using System;

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

   /// <summary> A constructor that constructs a CheckAccount on the 
   /// basis of an owner and the interestrate</summary>
   /// <param name = "o"> The owners name </param>
   /// <param name = "ir"> The interestrate </param>
   public CheckAccount(string o, double ir): 
     base(o, 0.0M, ir) {
   }

   /// <summary> A constructor that constructs a CheckAccount on the 
   /// basis of an owner, balance, and the interestrate</summary>
   /// <param name = "o"> The owners name </param>
   /// <param name = "b"> The initial balance of the account </param>
   /// <param name = "ir"> The interestrate </param>
   public CheckAccount(string o, decimal b, double ir): 
     base(o, b, ir) {
   }

   /// <summary> Withdraw an amount from the check account </summary>
   /// <param name = "amount"> The amount withdrawn </param>
   public override void Withdraw (decimal amount) {
      balance -= amount;
      if (amount < balance)
         interestRate = -0.10;
   }

   /// <summary> Returns a string which represents the account </summary>
   public override string ToString() {
      return owner + "'s check account holds " +
            + balance + " kroner";
   }
}