Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace HeadFirstDesignPatterns.Ch02TheObserverPattern.WeatherStation
- {
- class CurrentConditionsDisplay : Observer, DisplayElement
- {
- private float temperature;
- private float humidity;
- private Subject weatherData;
- public CurrentConditionsDisplay(Subject weatherData)
- {
- this.weatherData = weatherData;
- weatherData.RegisterObserver(this);
- }
- public void update(float temperature, float humidity, float pressure)
- {
- this.temperature = temperature;
- this.humidity = humidity;
- display();
- }
- public void display()
- {
- Console.WriteLine(String.Format("Current conditions: {0}F degrees and {1}% humidity", temperature,humidity));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement