using AddisonWesley.Michaelis.EssentialCSharp.Chapter14.Listing14_02;

namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter14.Listing14_11
{
    using System;
    using Listing14_01;

    public class Program
    {
        public static void Main()
        {
            Thermostat thermostat = new Thermostat();
            Heater heater = new Heater(60);
            Cooler cooler = new Cooler(80);
            string temperature;

            // Uwaga: w wersji C# 1.0 zastosuj kod
            // new Action (cooler.OnTemperatureChanged).
            thermostat.OnTemperatureChange =
                heater.OnTemperatureChanged;

            // Błąd: operator przypisania usuwa
            // wcześniej przypisane wartości.
            thermostat.OnTemperatureChange = 
                cooler.OnTemperatureChanged;

            Console.Write("Podaj temperaturę: ");
            temperature = Console.ReadLine();
            thermostat.CurrentTemperature = int.Parse(temperature);
        }
    }
}