Back to slide -- Keyboard shortcut: 'u'  previous -- Keyboard shortcut: 'p'  next -- Keyboard shortcut: 'n'          collections/dictionary/0/bank-account.cs - A class BankAccount.Lecture 12 - slide 27 : 36
Program 2

using System;

public class BankAccount {

   private double interestRate;
   private double balance;

   public BankAccount(double interestRate) {
      this.interestRate = interestRate;
      this.balance = 0.0;
   }

   public double Balance {
    get{
      return balance;
    }
   }

   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 "The account holds " +
            + balance + " kroner";
   }
}