static void Main(string[] args) { Hearter hearter = new Hearter(); Screen screen = new Screen(); hearter.Register(screen); hearter.BoilWater(); Console.ReadLine(); }
public void Updata(IObservable sender) { Hearter hearter = (Hearter)sender; if (!isDisplayedType) { Console.WriteLine("{0}-{1}:", hearter.Area, hearter.Type); Console.WriteLine(); isDisplayedType = true; } if (hearter.Temprature < 100) { Console.WriteLine("Alarm".PadRight(8) + ":水快烧开了,当前温度:{0}。", hearter.Temprature); } else { Console.WriteLine("Alarm".PadRight(8) + ":水已经烧开了!!"); } }