Example #1
0
        static void Main(string[] args)
        {
            var weatherStation          = new WeatherStation();
            var currentConditionDisplay = new CurrentConditionsDisplay();

            currentConditionDisplay.Subscribe(weatherStation);

            var forecastDisplay = new ForecastDisplay();

            forecastDisplay.Subscribe(weatherStation);

            var statisticsDisplay = new StatisticsDisplay();

            statisticsDisplay.Subscribe(weatherStation);

            var heatIndexDisplay = new HeatIndexDisplay();

            heatIndexDisplay.Subscribe(weatherStation);

            weatherStation.TrackWeather(new WeatherData(80, 65, 30.4f));
            weatherStation.TrackWeather(new WeatherData(82, 70, 29.2f));
            weatherStation.TrackWeather(new WeatherData(78, 90, 29.2f));

            Console.WriteLine();
            weatherStation.EndTransmission();
        }
        static void Main(string[] args)
        {
            WeatherData weatherData = new WeatherData();
            CurrentConditionsDisplay currentConditionsDisplay = new CurrentConditionsDisplay(weatherData);
            StatisticsDisplay        statisticsDisplay        = new StatisticsDisplay(weatherData);
            ForecastDisplay          forecastDisplay          = new ForecastDisplay(weatherData);
            HeatIndexDisplay         heatIndexDisplay         = new HeatIndexDisplay(weatherData);

            weatherData.SetMeasurements(80, 65, 30.4f);
            weatherData.SetMeasurements(82, 70, 29.2f);
            weatherData.SetMeasurements(78, 90, 29.2f);
        }
Example #3
0
        public void Run()
        {
            WeatherData wd = new WeatherData();

            CurrentConditionsDisplay currentConditionsDisplay = new CurrentConditionsDisplay(wd);
            StatisticsDisplay        statisticsDisplay        = new StatisticsDisplay(wd);
            ForecastDisplay          forecastDisplay          = new ForecastDisplay(wd);
            HeatIndexDisplay         heheatDisplay            = new HeatIndexDisplay(wd);

            wd.UpdateMeasurements(80, 65, 30.4f);
            wd.UpdateMeasurements(82, 70, 29.2f);
            wd.UpdateMeasurements(78, 90, 29.2f);
        }
        public static void Main()
        {
            WeatherData weatherData = new WeatherData();

            CurrentConditionsDisplay currentConditionsDisplay = new CurrentConditionsDisplay(weatherData);
            StatisticsDisplay        statisticsDisplay        = new StatisticsDisplay(weatherData);
            ForcastDisplay           forcastDisplay           = new ForcastDisplay(weatherData);
            HeatIndexDisplay         heatIndexDisplay         = new HeatIndexDisplay(weatherData);

            Console.WriteLine("The Weather Station App...");

            weatherData.SetMeasurements(80, 65, 30.4f);
            weatherData.SetMeasurements(82, 70, 29.2f);
            weatherData.SetMeasurements(78, 90, 29.2f);

            Console.ReadLine();
        }
        private static void DoWork()
        {
            WeatherProvider          weatherProvider   = new WeatherProvider();
            CurrentConditionsDisplay currentDisplay    = new CurrentConditionsDisplay();
            ForecastDisplay          forecastDisplay   = new ForecastDisplay();
            StatisticsDisplay        statisticsDisplay = new StatisticsDisplay();
            HeatIndexDisplay         heatIndexDisplay  = new HeatIndexDisplay();

            currentDisplay.Subscribe(weatherProvider);
            forecastDisplay.Subscribe(weatherProvider);
            statisticsDisplay.Subscribe(weatherProvider);
            heatIndexDisplay.Subscribe(weatherProvider);

            weatherProvider.SetMeasurements(80, 65, 30.4f);
            weatherProvider.SetMeasurements(82, 70, 29.2f);
            weatherProvider.SetMeasurements(78, 90, 29.2f);
            weatherProvider.EndService();
        }
Example #6
0
        static void Main(string[] args)
        {
            // Create new weather station object
            WeatherData weatherData = new WeatherData();

            // Create new displays and attach them to the new station in the constructor
            CurrentConditionDisplay currentDisplay    = new CurrentConditionDisplay(weatherData);
            StatisticsDisplay       statisticsDisplay = new StatisticsDisplay(weatherData);
            ForecastDisplay         forecastDisplay   = new ForecastDisplay(weatherData);
            HeatIndexDisplay        heatIndexDisplay  = new HeatIndexDisplay(weatherData);

            // Update the weather
            weatherData.SetMeasurements(80, 65, 30.4f);
            weatherData.SetMeasurements(82, 70, 29.2f);

            // Detach ForecastDisplay
            weatherData.Detach(forecastDisplay);

            // Update should now exclude the forecast text
            weatherData.SetMeasurements(78, 90, 29.2f);


            Console.Read();
        }