static void Main(string[] args) { var weatherData = new WeatherData(); var currentDisplay = new CurrentConditionsDisplay(weatherData); weatherData.SetMeasurements(80, 65, 30.4f); weatherData.SetMeasurements(82, 70, 29.2f); }
static void Main(string[] args) { WeatherData wd = new WeatherData(); CurrentConditions c = new CurrentConditions(wd); ForecastDisplay f = new ForecastDisplay(wd); wd.SetMeasurements(90, 67, 79); wd.SetMeasurements(90, 87, 79); }
static void Main(string[] args) { Console.WriteLine("Weather Station"); WeatherData weatherData = new WeatherData(); CurrentConditionsDisplay display = new CurrentConditionsDisplay(weatherData); weatherData.SetMeasurements(80, 65, 30.4f); weatherData.SetMeasurements(82, 70, 29.2f); weatherData.SetMeasurements(78, 90, 29.2f); }
static void Main(string[] args) { WeatherData weatherData = new WeatherData(); Observer currentConditionsDiaplay = new CurrentConditionsDisplay(weatherData); weatherData.SetMeasurements(24, 65, 30); weatherData.SetMeasurements(40, 1, 20); Console.ReadLine(); }
static void Main(string[] args) { WeatherData weatherData = new WeatherData(); CurrentConditionsDisplay currentConditionDisplay = new CurrentConditionsDisplay(weatherData); weatherData.SetMeasurements(80, 65, 30.4); weatherData.SetMeasurements(82, 70, 29.2); weatherData.SetMeasurements(78, 90, 29.2); }
static void Main(string[] args) { WeatherData weatherData = new WeatherData(); CurrentConditionsDisplay currentDisplay = new CurrentConditionsDisplay(weatherData); ProjectedConditionsDisplay projectedDisplay = new ProjectedConditionsDisplay(weatherData); weatherData.SetMeasurements(80, 65, 30.4f); weatherData.SetMeasurements(82, 70, 29.2f); weatherData.SetMeasurements(68, 90, 45.6f); Console.Read(); }
private static void WeatherStation() { var weatherData = new WeatherData(); var currentDisplay = new CurrentConditionDisplay(weatherData); var statisticsDisplay = new StatisticsDisplay(weatherData); var forcastDisplay = new ForcastDisplay(weatherData); weatherData.SetMeasurements(80, 65, 30.4f); weatherData.SetMeasurements(82, 70, 29.4f); weatherData.SetMeasurements(78, 80, 29.2f); }
static void Main(string[] args) { WeatherData weatherData = new WeatherData(); TemperatureObserver temperatureObserver = new TemperatureObserver(weatherData); PressureObserver pressureObserver = new PressureObserver(weatherData); weatherData.SetMeasurements(30, 20, 10); weatherData.SetMeasurements(20, 40, 5); weatherData.UnregisterObserver(temperatureObserver); weatherData.SetMeasurements(10, 50, 15); }
static void Main(string[] args) { WeatherData weatherData = new WeatherData(); CurrentConditionsDisplay currentDisplay = new CurrentConditionsDisplay(weatherData); ForecastDisplay forecastDisplay = new ForecastDisplay(weatherData); weatherData.SetMeasurements(80, 65, 30.4F); weatherData.SetMeasurements(82, 70, 29.2F); weatherData.SetMeasurements(78, 90, 29.2F); Console.ReadKey(); }
static void Main(string[] args) { var weatherData = new WeatherData(); new CurentConditionsDisplay(weatherData); new StatisticsDisplay(weatherData); weatherData.SetMeasurements(80, 65, 30.4f); weatherData.SetMeasurements(82, 70, 29.2f); weatherData.SetMeasurements(78, 90, 29.2f); Console.ReadKey(); }
private static void Main(string[] args) { var weatherData = new WeatherData(); var currentConditionsDisplay = new CurrentConditionsDisplay(weatherData); weatherData.SetMeasurements(80, 65, 30.4f); currentConditionsDisplay.Unsubscribe(); weatherData.SetMeasurements(80, 65, 30.4f); }
static void Main(string[] args) { WeatherData weatherData = new WeatherData(); CurrentConditionsDisplay currentConditions = new CurrentConditionsDisplay(weatherData); HeatIndex heatIndex = new HeatIndex(weatherData); weatherData.SetMeasurements(12, 43, 76); weatherData.SetMeasurements(43, 32, 63); weatherData.SetMeasurements(32, 43, 53); Console.ReadKey(); }
static void Main(string[] args) { WeatherData wd = new WeatherData(); CurrentConditionsDisplay cd = new CurrentConditionsDisplay(wd); wd.SetMeasurements(80, 65, 30.4f); wd.SetMeasurements(82, 70, 29.2f); wd.SetMeasurements(78, 90, 29.2f); while (true) { } }
static void Main(string[] args) { var weatherData = new WeatherData(); var forecastDisplay = new ForecastDisplay(weatherData); var statisticsDisplay = new StatisticsDisplay(weatherData); var thirdPartyDisplay = new ThirdPartyDisplay(weatherData); var currentConditionsDisplay = new CurrentConditionsDisplay(weatherData); weatherData.SetMeasurements(80.0f, 100.0f, 1100.012f); weatherData.SetMeasurements(90.0f, 130.0f, 1500.012f); weatherData.SetMeasurements(910.0f, 120.0f, 1700.012f); }
static void Main(string[] args) { var weatherData = new WeatherData(); new CurentConditionsDisplay(weatherData); new StatisticsDisplay(weatherData); weatherData.SetMeasurements(80, 65, 30.4f); weatherData.SetMeasurements(82, 70, 29.2f); weatherData.SetMeasurements(78, 90, 29.2f); Console.ReadKey(); }
static void Main(string[] args) { var weatherData = new WeatherData(); var currentConditions = new CurrentConditionsDisplay(weatherData); var averageTemperature = new AverageTemperatureDisplay(weatherData); weatherData.SetMeasurements(72, 30, 25); weatherData.SetMeasurements(75, 32, 30); weatherData.SetMeasurements(80, 25, 20); Console.ReadLine(); }
static void Main(string[] args) { WeatherData weatherData = new WeatherData(); CurrentConditionsDisplay current = new CurrentConditionsDisplay(weatherData); StatisticsDisplay statistics = new StatisticsDisplay(weatherData); weatherData.SetMeasurements(80f, 65f, 30.4f); weatherData.SetMeasurements(90f, 70f, 34.4f); weatherData.SetMeasurements(85f, 60f, 29.4f); Console.ReadKey(); }
static void Main(string[] args) { WeatherData weatherData = new WeatherData(); CurrentConditionsDisplay currentDisplay = new CurrentConditionsDisplay(weatherData); weatherData.RegisterObserver(currentDisplay); weatherData.SetMeasurements(80, 65, 30.4); weatherData.SetMeasurements(82, 70, 29.2); weatherData.SetMeasurements(78, 90, 29.2); Console.ReadKey(); }
private static void Main(string[] args) { WeatherData weatherData = new WeatherData(); CurrentConditionsDisplay currentDisplay = new CurrentConditionsDisplay(weatherData); //StatisticsDisplay statisticsDisplay = new StatisticsDisplay(weatherData); //ForecastDisplay forecastDisplay = new ForecastDisplay(weatherData); weatherData.SetMeasurements(80, 65, 30.4f); weatherData.SetMeasurements(80, 70, 29.3f); weatherData.SetMeasurements(78, 90, 29.2f); Console.ReadKey(); }
static void Main(string[] args) { WeatherData wd = new WeatherData(); IDisplayElement currentConditionsDisplay = new CurrentConditionDisplay(wd); IDisplayElement statisticsDisplay = new StatisticsDisplay(wd); IDisplayElement forecastDisplay = new ForecastDisplay(wd); wd.SetMeasurements(80, 65, 30.4); Task.Delay(2000).Wait(); wd.SetMeasurements(82, 70, 29.2); Task.Delay(2000).Wait(); wd.SetMeasurements(78, 90, 29.2); }
static void Main(string[] args) { var weatherData = new WeatherData(); var currentDisply = new CurrentConditionDisplay(weatherData); var heatIndexDisplay = new HeatIndexDisplay(weatherData); var forecast = new ForecastDisplay(weatherData); weatherData.Temperature = 80; Console.WriteLine("------------------------------------------"); weatherData.Humidity = 65; Console.WriteLine("------------------------------------------"); weatherData.Pressure = 30.4f; Console.WriteLine("------------------------------------------"); weatherData.SetMeasurements(82, 70, 29.2f); Input(weatherData); }
static void Main(string[] args) { Console.WriteLine("Weather Station"); Console.WriteLine(); WeatherData weatherData = new WeatherData(); CurrentConditionsDisplay currentDisplay = new CurrentConditionsDisplay(weatherData); StatisticsDisplay statisticsDisplay = new StatisticsDisplay(weatherData); ForecastDisplay forecastDisplay = new ForecastDisplay(weatherData); HeatIndexDisplay heatIndexDisplay = new HeatIndexDisplay(weatherData); weatherData.SetMeasurements(80, 65, 30.4f); Console.WriteLine(); weatherData.SetMeasurements(87, 70, 29.2f); Console.WriteLine(); weatherData.SetMeasurements(78, 90, 29.2f); Console.WriteLine(); }
static void Main(string[] args) { //Create the weatherData object WeatherData weatherData = new WeatherData(); //Create the 3 displays and pass them the weatherData object CurrentConditionDisplay currentDisplay = new CurrentConditionDisplay(weatherData); StatisticsDisplay statisticsDisplay = new StatisticsDisplay(weatherData); ForecastDisplay forecastDisplay = new ForecastDisplay(weatherData); //Add the new heat index display HeatIndexDisplay heatIndexDisplay = new HeatIndexDisplay(weatherData); //Input data (from fictional weather station) weatherData.SetMeasurements(80, 65, 30.4f); weatherData.SetMeasurements(82, 70, 29.2f); weatherData.SetMeasurements(78, 90, 29.2f); //Show display output in console Console.ReadLine(); }
static void Main(string[] args) { WeatherData weatherData = new WeatherData(); BaseDisplay currentConditionsDisplay = new HeatDisplay(weatherData); weatherData.SetMeasurements(new WeatherDto() { Humidity = 13.2f, Pressure = 1031f, Temperature = 31.2f }); weatherData.SetMeasurements(new WeatherDto() { Humidity = 24.3f, Pressure = 1080f, Temperature = 42.2f }); }
static void Main(string[] args) { Console.WriteLine("*** Observer ***"); WeatherData weatherData = new WeatherData(); CurrentConditionalDisplay conditionalDisplay = new CurrentConditionalDisplay(weatherData); StatisticsDisplay statisticsDisplay = new StatisticsDisplay(weatherData); ForecastDisplay forecastDisplay = new ForecastDisplay(weatherData); HeatIndexDisplay heatIndexDisplay = new HeatIndexDisplay(weatherData); weatherData.SetMeasurements(26, 65, 760); weatherData.SetMeasurements(30, 70, 750); weatherData.SetMeasurements(0, 90, 790); #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) { /* * The Observer Pattern: defines a one-to-many * dependency between objects so that when one * object changes state, all of its dependents are * notified and updated automatically. * * Design principle: Strive for loosely coupled designs between objects that interact. * */ WeatherData weatherData = new WeatherData(); CurrentConditionsDisplay currentConditionsDisplay = new CurrentConditionsDisplay(weatherData); weatherData.SetMeasurements(80, 65, 30.4f); weatherData.SetMeasurements(82, 70, 29.2f); weatherData.SetMeasurements(78, 90, 29.2f); Console.ReadKey(); }
static void Input(WeatherData weatherData) { Console.WriteLine("------------------------------------------"); Console.WriteLine("To update weather measurements please enter the following format temperature,humidity,pressure (ex. 80,65,30.4)"); var input = Console.ReadLine(); // Get string from user if (input != null) { var inputs = input.Split(','); weatherData.SetMeasurements( Convert.ToSingle(inputs[0]), Convert.ToSingle(inputs[1]), Convert.ToSingle(inputs[2]) ); } Input(weatherData); }
static void Input(WeatherData weatherData) { Console.WriteLine("------------------------------------------"); Console.WriteLine("To update weather measurements please enter the following format temperature,humidity,pressure (ex. 80,65,30.4)"); var input = Console.ReadLine(); // Get string from user if (input != null) { var inputs = input.Split(','); weatherData.SetMeasurements( Convert.ToSingle(inputs[0]), Convert.ToSingle(inputs[1]), Convert.ToSingle(inputs[2]) ); } Input(weatherData); }
static void Main(string[] args) { var weatherData = new WeatherData(); var currentDisply = new CurrentConditionDisplay(weatherData); var heatIndexDisplay = new HeatIndexDisplay(weatherData); var forecast = new ForecastDisplay(weatherData); weatherData.Temperature = 80; Console.WriteLine("------------------------------------------"); weatherData.Humidity = 65; Console.WriteLine("------------------------------------------"); weatherData.Pressure = 30.4f; Console.WriteLine("------------------------------------------"); weatherData.SetMeasurements(82, 70, 29.2f); Input(weatherData); }