static void Main(string[] args)
        {
            var weatherData             = new WeatherData();
            var currentConditionsReport = new CurrentConditionsReport();
            var statisticsReport        = new StatisticReport();

            weatherData.Register(currentConditionsReport);
            weatherData.Register(statisticsReport);

            var weatherInfo = new WeatherInfo()
            {
                Temperature = 10, Humidity = 15, Pressure = 30
            };

            weatherData.UpdateWeatherInfo(weatherInfo);

            Console.WriteLine(currentConditionsReport.MakeReport() + "\n\n");
            Console.WriteLine(statisticsReport.MakeReport() + "\n\n");

            weatherInfo.Temperature = -10;
            weatherInfo.Humidity    = 3;
            weatherInfo.Pressure    = 87;
            weatherData.UpdateWeatherInfo(weatherInfo);

            Console.WriteLine(currentConditionsReport.MakeReport() + "\n\n");
            Console.WriteLine(statisticsReport.MakeReport() + "\n\n");
        }
Esempio n. 2
0
        static void Main(string[] args)
        {
            WeatherData             data = new WeatherData();
            CurrentConditionsReport currentConditionsReport = new CurrentConditionsReport();
            StatisticReport         statisticReport         = new StatisticReport();

            data.Register(currentConditionsReport);
            data.Register(statisticReport);
            int    time = 0, period = 0;
            string str = " ";

            while (!int.TryParse(str, out time) || time < 0)
            {
                Console.WriteLine("Enter time in seconds: ");
                str = Console.ReadLine();
            }

            str = " ";
            while (!int.TryParse(str, out period) || period < 0)
            {
                Console.WriteLine("Enter period in milliseconds: ");
                str = Console.ReadLine();
            }

            Start(time, period, data);

            Console.WriteLine(statisticReport.GenerateReport());
        }
        static void Main(string[] args)
        {
            WeatherData             waetherStation   = new WeatherData();
            CurrentConditionsReport conditionsReport = new CurrentConditionsReport();
            StatisticReport         statisticReport  = new StatisticReport();

            waetherStation.Register(conditionsReport);
            waetherStation.Register(statisticReport);
            waetherStation.Unregister(statisticReport);

            waetherStation.StartNotify();
        }
Esempio n. 4
0
        private static void Main(string[] args)
        {
            weather   = new WeatherData();
            statistic = new StatisticReport();
            current   = new CurrentConditionsReport();

            weather.Register(statistic);
            weather.Register(current);

            Thread getThread = new Thread(GetReports);

            getThread.Start();
            weather.StartGenerator();
        }
Esempio n. 5
0
        static void Main(string[] args)
        {
            WeatherData weatherData = new WeatherData();

            CurrentConditionsReport current   = new CurrentConditionsReport();
            StatisticReport         statistic = new StatisticReport(10, 80, 756);

            weatherData.Register(current);
            weatherData.Register(statistic);

            weatherData.EmulateWeatherChange();
            weatherData.EmulateWeatherChange();

            Console.ReadKey();
        }
        static void Main(string[] args)
        {
            var weatherData              = new WeatherData();
            var currentConditionsReport  = new CurrentConditionsReport();
            var currentConditionsReport1 = new CurrentConditionsReport();
            var statisticReport          = new StatisticReport();

            weatherData.Register(statisticReport);
            weatherData.Register(currentConditionsReport);
            weatherData.Register(currentConditionsReport1);

            Thread weatherStationThread = new Thread(weatherData.GenerateInfo);

            weatherStationThread.Start();

            Thread.Sleep(10000);
            weatherData.Unregister(currentConditionsReport);
        }
Esempio n. 7
0
        static void Main(string[] args)
        {
            Console.WriteLine("Create Current Conditions Report");
            CurrentConditionsReport conditionsReport = new CurrentConditionsReport();

            Console.WriteLine("Create Statistic Report");
            StatisticReport statisticReport = new StatisticReport();

            Console.WriteLine("Create observable object: Weather data");
            WeatherData weatherData = new WeatherData(50, 2);

            Console.WriteLine("Register observers Current Conditions Report and Statistic Report");
            weatherData.Register(conditionsReport);
            weatherData.Register(statisticReport);

            weatherData.StartMeasure();
            Console.ReadLine();
        }
Esempio n. 8
0
 public CurrentConditionsDisplay(WeatherData weatherData)
 {
     _weatherData = weatherData;
     _weatherData.Register(this);
 }
Esempio n. 9
0
		public HeatIndexDisplay(WeatherData weatherData)
		{
			_weatherData = weatherData;
			_weatherData.Register(this);
		}
Esempio n. 10
0
 public StatisticsDisplay(WeatherData weatherData)
 {
     _weatherData = weatherData;
     _weatherData.Register(this);
 }
Esempio n. 11
0
 public ForecastDisplay(WeatherData weatherData)
 {
     _weatherData = weatherData;
     _weatherData.Register(this);
 }