public ConcreteObserver( ConcreteSubject subject, string name) { this._subject = subject; this._name = name; }
private void btnObsever_Click(object sender, EventArgs e) { ConcreteSubject s = new ConcreteSubject(); s.Attach(new ConcreteObserver(s, "X")); s.Attach(new ConcreteObserver(s, "Y")); s.Attach(new ConcreteObserver(s, "Z")); s.SubjectState = "ABC"; s.Notify(); //IBM ibm = new IBM("IBM", 120.00); //ibm.Attach(new Investor("Sorros")); //ibm.Attach(new Investor("Berkshire")); //// Fluctuating prices will notify investors //ibm.Price = 120.10; //ibm.Price = 121.00; // Wait for user }