bank-account/bank-account-1/bank-account-client.cs - 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); } }