protected virtual void Notify(BoiledEventArgs e) { foreach (IObserver observer in container) { observer.Update(e); } }
protected virtual void OnBoiled(BoiledEventArgs e) { base.Notify(e); }
public void Update(BoiledEventArgs e) { if (!isDispalyedType) { Console.WriteLine("{0}-{1}", e.Area, e.Type); Console.WriteLine(); isDispalyedType = true; } if (e.Temperature < 100) { Console.WriteLine( string.Format("Screen".PadRight(7) + "water will bored,current temperatur:{0}", e.Temperature.ToString()) ); } else { Console.WriteLine(string.Format("Screen".PadRight(7) + "water ok.")); } }
public void BoilWater() { for (int i = 0; i <=99; i++) { temprature = i + 1; if (temprature > 97) { BoiledEventArgs e = new BoiledEventArgs(temprature,type,area); OnBoiled(e); } } }