Friday, October 19, 2007

Observer Pattern (4) MainApp


// MainApp test application

class MainApp

{

static void Main()

{

// Create investors

Investor s = new Investor("Sorros");

Investor b = new Investor("Berkshire");

// Create IBM stock and attach investors

IBM ibm = new IBM("IBM", 120.00);

ibm.Attach(s);

ibm.Attach(b);

// Change price, which notifies investors

ibm.Price = 120.10;

ibm.Price = 121.00;

ibm.Price = 120.50;

ibm.Price = 120.75;

// Wait for user

Console.Read();

}

}

blog comments powered by Disqus