Back to notes -- Keyboard shortcut: 'u'        next -- Keyboard shortcut: 'n'  Slide program -- Keyboard shortcut: 't'    The class BankAccount.Lecture 14 - slide 22 : 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) {
   }

   public BankAccount(string owner, double balance): 
     this(owner, balance, 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";
   }
}