static void Main(string[] args) { WeatherStation station = new WeatherStation(); station.Subscribe(new Gismeteo()); station.Subscribe(new StreetWeatherStand()); station.Subscribe(new WeatherForecast()); station.Notify(new WeatherInfo() { Temperature = 30, WindSpeed = 2 }); Console.WriteLine("----------------------------------------------------\n"); station.Notify(new WeatherInfo() { Temperature = -5, WindSpeed = 12 }); }
static void Main(string[] args) { /* * each observer can set customized temperature and pressure alert levels; * observer is notified each time the weather data changes and is being sent extra alerts based on own * temperature and pressure alert levels */ WeatherStation weatherStation = new WeatherStation(); weatherStation.Add(new Observer(weatherStation, "Observer 1", -15, 30, 1000, 1050)); weatherStation.Add(new Observer(weatherStation, "Observer 2", 0, 25, 1010, 1040)); weatherStation.Notify(); }