Example #1
0
 //报纸接口
 private static void Main(string[] args)
 {
     var paper = new PeopleNewsPaper();
     var xiaoMing = new SubHuman("小明");
     var zhaoYun = new SubHuman("赵云");
     var liuBei = new SubHuman("刘备");
     paper.RegisterSubscriber(xiaoMing); //小明订报
     paper.RegisterSubscriber(zhaoYun); //赵云订报
     paper.RegisterSubscriber(liuBei); //刘备订报
     paper.SendPaper(); //有新报纸了
     Console.WriteLine("---------------发完报纸了------------------");
     paper.RemoveSubScriber(xiaoMing); //小明不想订了,取消报纸
     paper.SendPaper(); //又有新报纸了  就没有小明的报纸 了
     Console.ReadLine();
 }
Example #2
0
        //报纸接口
        private static void Main(string[] args)
        {
            var paper    = new PeopleNewsPaper();
            var xiaoMing = new SubHuman("小明");
            var zhaoYun  = new SubHuman("赵云");
            var liuBei   = new SubHuman("刘备");

            paper.RegisterSubscriber(xiaoMing); //小明订报
            paper.RegisterSubscriber(zhaoYun);  //赵云订报
            paper.RegisterSubscriber(liuBei);   //刘备订报
            paper.SendPaper();                  //有新报纸了
            Console.WriteLine("---------------发完报纸了------------------");
            paper.RemoveSubScriber(xiaoMing);   //小明不想订了,取消报纸
            paper.SendPaper();                  //又有新报纸了  就没有小明的报纸 了
            Console.ReadLine();
        }