Beispiel #1
0
        static void Main(string[] args)
        {
            //A celebrity
            Celebrity tomCruise = new Celebrity();

            //some fans
            HappyFan fan1 = new HappyFan();
            HappyFan fan2 = new HappyFan();
            SadFan fan3 = new SadFan();
            SadFan fan4 = new SadFan();

            //fans registering against an event in celebrity life so that they can be notified when that event occurs
            fan1.Register(tomCruise);
            fan2.Register(tomCruise);
            fan3.Register(tomCruise);
            fan4.Register(tomCruise);

            //triggering the event
            tomCruise.Suicide();
        }
Beispiel #2
0
 public void Register(Celebrity c)
 {
     c.fansToNotify += Weep;
 }
Beispiel #3
0
 public void Register(Celebrity c)
 {
     c.fansToNotify += Laugh;
 }