Пример #1
0
        static void Main(string[] args)
        {
            Thermometer        thermometer = new Thermometer();
            ThermometerDisplay display1    = new ThermometerDisplay(1, thermometer);
            ThermometerDisplay display2    = new ThermometerDisplay(2, thermometer);
            ThermometerDisplay display3    = new ThermometerDisplay(3, thermometer);

            thermometer.AddObserver(display1);
            thermometer.AddObserver(display2);
            thermometer.AddObserver(display3);

            thermometer.ReadTemperature();
            thermometer.RemoveObserver(display1);
            thermometer.ReadTemperature();
            thermometer.AddObserver(display1);

            thermometer.ReadTemperature();
            thermometer.ReadTemperature();
            thermometer.ReadTemperature();
        }