public void BoilWater() { for (int i = 0; i < 100; i++) { temperature = i; if (temperature > 95) { var e = new BoiledEventArgs(temperature); this.Boil(e); } } }
// 显示水温 public void Show(Object sender, BoiledEventArgs e) { Console.WriteLine("Display:水快开了,当前温度:{0}度。", e.Temperature); }
public void Alert(Object sender, BoiledEventArgs e) { Console.WriteLine("Alarm:嘀嘀嘀,水已经 {0} 度了:", e.Temperature); }