Back to slide -- Keyboard shortcut: 'u'        next -- Keyboard shortcut: 'n'  Annotated program -- Keyboard shortcut: 't'    patterns/observer/template/subject-only.cs - Template of the Subject class.Lecture 6 - slide 17 : 20
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
 }
}