public static void SimpleObserverTest() { Console.WriteLine("简单实现的观察者模式:"); Console.WriteLine("======================="); //1、初始化鱼竿 var fishingRod = new FishingRod(); //2、声明垂钓者 var jeff = new FishingMan("Tommy"); //3、将垂钓者观察鱼竿 fishingRod.AddSubscriber(jeff); //4、循环钓鱼 while (jeff.FishCount < 100) { fishingRod.Fishing(); Console.WriteLine("-------------------"); //睡眠5s Thread.Sleep(5000); } }