patterns/observer/template/subject-only.cs - Templates of the Subject class and the SubjectState class. | Lecture 5 - slide 42 : 45 Program 1 |
using System.Collections; namespace Templates.Observer { public class Subject { // Subject instance variables private ArrayList observers = new ArrayList(); public void Attach(Observer o){ observers.Add(o); } public void Detach(Observer o){ observers.Remove(o); } public void Notify(){ foreach(Observer o in observers) o.Update(); } public SubjectState GetState(){ return new SubjectState(); } } public class SubjectState { // Selected state of the subject } }