示例#1
0
        static void Main(string[] args)
        {
            //前臺小姐童子喆
            Secretary tongzizhe = new Secretary();
            //看股票的同事
            StockObserver tongshi1 = new StockObserver("魏關奼", tongzizhe);
            StockObserver tongshi2 = new StockObserver("易管查", tongzizhe);

            //前臺記下了兩位同事
            tongzizhe.Attach(tongshi1);
            tongzizhe.Attach(tongshi2);
            //發現老闆回來
            tongzizhe.SecretaryAction = "老闆回來了!";
            //通知兩個同事
            tongzizhe.Notify();

            Console.Read();
        }
示例#2
0
        static void Main(string[] args)
        {
            //前臺小姐童子喆
            Secretary tongzizhe = new Secretary();
            //看股票的同事
            StockObserver tongshi1 = new StockObserver("魏關奼", tongzizhe);
            StockObserver tongshi2 = new StockObserver("易管查", tongzizhe);

            //前臺記下了兩位同事
            tongzizhe.Attach(tongshi1);
            tongzizhe.Attach(tongshi2);
            //發現老闆回來
            tongzizhe.SecretaryAction = "老闆回來了!";
            //通知兩個同事
            tongzizhe.Notify();

            Console.Read();
        }
示例#3
0
        static void Main(string[] args)
        {
            //老板胡漢三
            Boss huhansan = new Boss();

            //看股票的同事
            StockObserver tongshi1 = new StockObserver("魏關奼", huhansan);
            //看NBA的同事
            NBAObserver tongshi2 = new NBAObserver("易管查", huhansan);

            huhansan.Update += new EventHandler(tongshi1.CloseStockMarket);
            huhansan.Update += new EventHandler(tongshi2.CloseNBADirectSeeding);

            //老闆回來
            huhansan.SubjectState = "我胡漢三回來了!";
            //發出通知
            huhansan.Notify();

            Console.Read();
        }
示例#4
0
        static void Main(string[] args)
        {
            //老板胡漢三
            Boss huhansan = new Boss();

            //看股票的同事
            StockObserver tongshi1 = new StockObserver("魏關奼", huhansan);
            //看NBA的同事
            NBAObserver tongshi2 = new NBAObserver("易管查", huhansan);

            huhansan.Attach(tongshi1);
            huhansan.Attach(tongshi2);

            huhansan.Detach(tongshi1);

            //老闆回來
            huhansan.SubjectState = "我胡漢三回來了!";
            //發出通知
            huhansan.Notify();

            Console.Read();
        }
示例#5
0
        static void Main(string[] args)
        {
            //老板胡漢三
            Boss huhansan = new Boss();

            //看股票的同事
            StockObserver tongshi1 = new StockObserver("魏關奼", huhansan);
            //看NBA的同事
            NBAObserver tongshi2 = new NBAObserver("易管查", huhansan);

            huhansan.Update += new EventHandler(tongshi1.CloseStockMarket);
            huhansan.Update += new EventHandler(tongshi2.CloseNBADirectSeeding);

            //老闆回來
            huhansan.SubjectState = "我胡漢三回來了!";
            //發出通知
            huhansan.Notify();

            Console.Read();
        }
示例#6
0
 //減少
 public void Detach(StockObserver observer)
 {
     observers.Remove(observer);
 }
示例#7
0
 //增加
 public void Attach(StockObserver observer)
 {
     observers.Add(observer);
 }
示例#8
0
 //減少
 public void Detach(StockObserver observer)
 {
     observers.Remove(observer);
 }
示例#9
0
 //增加
 public void Attach(StockObserver observer)
 {
     observers.Add(observer);
 }
示例#10
0
        static void Main(string[] args)
        {
            //老板胡漢三
            Boss huhansan = new Boss();

            //看股票的同事
            StockObserver tongshi1 = new StockObserver("魏關奼", huhansan);
            //看NBA的同事
            NBAObserver tongshi2 = new NBAObserver("易管查", huhansan);

            huhansan.Attach(tongshi1);
            huhansan.Attach(tongshi2);

            huhansan.Detach(tongshi1);

            //老闆回來
            huhansan.SubjectState = "我胡漢三回來了!";
            //發出通知
            huhansan.Notify();

            Console.Read();
        }