Back to slide -- Keyboard shortcut: 'u'        next -- Keyboard shortcut: 'n'          unit-testing/bank-not-ok/bank-account.cs - The class BankAccount - with an error.Lecture 14 - slide 23 : 35
Program 1

using System;

public class BankAccount {

   private double interestRate;
   private string owner;
   private double balance;

   public BankAccount(string owner): 
     this(owner, 0.0, 0.0) {
   }

   /* Wrong initialization of interest rate */
   public BankAccount(string owner, double balance): 
     this(owner, balance, 0.01) {           // Should have been 0.0
   }

   public BankAccount(string owner, double balance, double interestRate) {
      this.interestRate = interestRate;
      this.owner = owner; 
      this.balance = balance;
   }

   public double Balance {
     get{
      return balance;
     }
   }

   public double InterestRate {
     get{
      return interestRate;
     }
   }

   public void Withdraw (double amount) {
      balance -= amount;
   }

   public void Deposit (double amount) {
      balance += amount;
   }

   public void AddInterests() {
      balance = balance + balance * interestRate;
   }    

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