Exemple #1
0
        static void Main(string[] args)
        {
            WeatherInfo             weatherInfo = new WeatherInfo();
            CurrentConditionsReport report1     = new CurrentConditionsReport();

            report1.Register(weatherInfo);
            StatisticReport report2 = new StatisticReport();

            report2.Register(weatherInfo);
            ForeCastReport report3 = new ForeCastReport();

            report3.Register(weatherInfo);
            weatherInfo.NewDay(12, 23, 567);
            weatherInfo.NewDay(18, 80, 357);
            weatherInfo.NewDay(18, 96, 357);

            report1.Unregister(weatherInfo);
            report2.Unregister(weatherInfo);
            report3.Unregister(weatherInfo);
        }
        static void Main(string[] args)
        {
            WeatherDataManager dataManager = new WeatherDataManager();

            CurrentConditionReport sub1 = new CurrentConditionReport();
            ForeCastReport         sub2 = new ForeCastReport();
            StatisticReport        sub3 = new StatisticReport();;

            sub1.Register(dataManager);

            dataManager.WeatherChange(100, 200, 300);

            sub2.Register(dataManager);
            sub3.Register(dataManager);

            dataManager.WeatherChange(100, 200, 300);

            sub2.Unregister(dataManager);
            dataManager.WeatherChange(100, 200, 300);

            System.Console.ReadKey();
        }