Exemplo n.º 1
0
        static void Main(string[] args)
        {
            Secretary tongzijie = new Secretary();

            StockObserver tongshi1 = new StockObserver("张三", tongzijie);
            StockObserver tongshi2 = new StockObserver("李四", tongzijie);

            tongzijie.Attach(tongshi1);
            tongzijie.Attach(tongshi2);

            tongzijie.SecretaryAction = "老板回来了!";
            tongzijie.Notify();
            Console.ReadLine();
        }
Exemplo n.º 2
0
 /// <summary>
 /// 增加
 /// </summary>
 /// <param name="observer"></param>
 public void Attach(StockObserver observer)
 {
     observers.Add(observer);
 }