Example #1
0
 public void NotifyObserver(Observable observable)
 {
     foreach (Observer ob in this.Observers)
     {
         ob.update(observable);
     }
 }
Example #2
0
 public void update(Observable observable)
 {
     Water water = (Water)observable;
     if (water.GetTemp() >= 40)
     {
         Console.WriteLine("当前水的状态:温水");
     }
     else if(water.GetTemp() < 40)
     {
         Console.WriteLine("当前水的状态:凉白开");
     }
 }
Example #3
0
 public void update(Observable observable)
 {
     Water water = (Water)observable;
     Console.WriteLine("当前水的温度是:" + water.GetTemp());
 }