Back to notes -- Keyboard shortcut: 'u'  previous -- Keyboard shortcut: 'p'        Slide program -- Keyboard shortcut: 't'    A typical problem: A class method that accesses instance variables.Lecture 3 - slide 16 : 29
Program 4
using System;

public class BankAccountClient {

  BankAccount 
    a1 = new BankAccount("Kurt", 0.02),    // Error:
    a2 = new BankAccount("Bent", 0.03),    // An object reference is 
    a3 = new BankAccount("Thomas", 0.02);  // required for the
                                           // nonstatic field
  public static void Main(){

    a1.deposit(100.0);                      
    a2.deposit(1000.0); a2.addInterests();  
    a3.deposit(3000.0); a3.addInterests();  
                                            
    Console.WriteLine(a1); 
    Console.WriteLine(a2); 
    Console.WriteLine(a3); 
  }

}
 
 
 
 
 
 
 
 
 
 
 
a1 refers to an instance
variable in class BankAccountClient.
There exists no instances of this
class BankAccountClient.