Beispiel #1
0
        private static void Main(string[] args)
        {
            var weatherStation = new WeatherStation();
            var tvDisplay      = new TvDisplay();
            var phoneDisplay   = new PhoneDisplay();

            weatherStation.AddObserver(tvDisplay);
            weatherStation.AddObserver(phoneDisplay);

            while (true)
            {
                weatherStation.Broadcast(string.Format("Hello display {0}", DateTime.UtcNow));
                Thread.Sleep(1000);
            }
        }
        static void Main(string[] args)
        {
            var weatherStation = new WeatherStation();

            var newsChannel1 = new NewsChannel("Independence TV");

            weatherStation.AddObserver(newsChannel1);

            var newsChannel2 = new NewsChannel("India Tomorrow");

            weatherStation.AddObserver(newsChannel2);

            weatherStation.Temperature = 10.2f;
            weatherStation.Temperature = 23.2f;
            weatherStation.Temperature = 45.2f;
        }