Advertisement
Fhernd

CurrentConditionsDisplayWithEventsAndDelegates.cs

Mar 13th, 2013
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.81 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 CurrentConditionsDisplayWithEventsAndDelegates : IObserverWithEventsAndDelegates, DisplayElementWithEventsAndDelegates
  10.     {
  11.         private float temperature;
  12.         private float humidity;
  13.  
  14.         public void Update(float temperature, float humidity, float pressure)
  15.         {
  16.             this.temperature = temperature;
  17.             this.humidity = humidity;
  18.             Display();
  19.         }
  20.  
  21.         public void Display()
  22.         {
  23.             Console.WriteLine(String.Format("Current conditions: {0}F degrees and {1}% humidity", temperature, humidity));
  24.         }
  25.     }
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement