Advertisement
Fhernd

WeatherStationWithEventsAndDelegates.cs

Mar 13th, 2013
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.38 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace HeadFirstDesignPatterns.Ch02TheObserverPattern.WeatherStationWithEventsAndDelegates
  8. {
  9.     class WeatherStationWithEventsAndDelegatesProgram
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             CurrentConditionsDisplayWithEventsAndDelegates currentConditionsDisplay = new CurrentConditionsDisplayWithEventsAndDelegates();
  14.             ForecastDisplayWithEventsAndDelegates forecastDisplay = new ForecastDisplayWithEventsAndDelegates();
  15.             HeatIndexDisplayWithEventsAndDelegates heatIndexDisplay = new HeatIndexDisplayWithEventsAndDelegates();
  16.             StatisticsDisplayWithEventsAndDelegates statisticsDisplay = new StatisticsDisplayWithEventsAndDelegates();
  17.  
  18.             WeatherDataWithEventsAndDelegates weatherObject = new WeatherDataWithEventsAndDelegates();
  19.  
  20.             weatherObject.MeasurementsChanged += currentConditionsDisplay.Update;
  21.             weatherObject.MeasurementsChanged += forecastDisplay.Update;
  22.             weatherObject.MeasurementsChanged += heatIndexDisplay.Update;
  23.             weatherObject.MeasurementsChanged += statisticsDisplay.Update;
  24.  
  25.             weatherObject.NewWeather(80, 65, 30);
  26.             weatherObject.NewWeather(82, 70, 29);
  27.             weatherObject.NewWeather(79, 90, 29);
  28.         }
  29.     }
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement