static void Main(string[] args) { Console.WriteLine("Hello World!"); WeatherObservable weatherObservable = new WeatherObservable(); CurrentCondition currentCondition = new CurrentCondition(weatherObservable); weatherObservable.GetMeasurements(new Measurements(10, 60, 760)); weatherObservable.GetMeasurements(null); #if (!vscode) // Add this for run from VS in order to console window will keep open Console.WriteLine("Press Enter for exit"); Console.ReadLine(); #endif }
static void Main(string[] args) { WeatherObservable weatherObservable = new WeatherObservable(0, 0, 0); CurrentConditionsDisplay currentConditionsDisplay = new CurrentConditionsDisplay(weatherObservable, 0, 0); weatherObservable.SetTemperature(10); weatherObservable.SetHumidity(20); weatherObservable.SetPressure(20); weatherObservable.RemoveObserver(currentConditionsDisplay); StatisticsDisplay statisticsDisplay = new StatisticsDisplay(weatherObservable, 0); weatherObservable.SetMeasurements(100, 200, 200); }
public static void Main(string[] args) { WeatherObservable weatherReporter = new WeatherObservable(); WeatherData wd = new WeatherData(); wd.SetMeasurements(48.0f, .50f, 10.0f); CurrentConditionsDisplay display = new CurrentConditionsDisplay(); using (IDisposable disposable = weatherReporter.Subscribe(display)) { weatherReporter.UpdateWeather(wd, false); wd = new WeatherData(); wd.SetMeasurements(105.0f, .89f, 32.0f); weatherReporter.UpdateWeather(wd, false); wd = new WeatherData(); wd.SetMeasurements(17.5f, .16f, 12.0f); weatherReporter.UpdateWeather(wd, false); weatherReporter.CloseAllStationReports(); } }
public CurrentCondition(WeatherObservable weatherObservable) { weatherObservable.Observers += Update; }