Exemplo n.º 1
0
        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);
        }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            WeatherData weatherData = new WeatherData();

            CurrentConditionsDisplay currentDisplay    = new CurrentConditionsDisplay(weatherData);
            StatisticsDisplay        statisticsDisplay = new StatisticsDisplay(weatherData);
            ForecastDisplay          forecastDisplay   = new ForecastDisplay(weatherData);
            HeatIndexDisplay         heatIndexDisplay  = new HeatIndexDisplay(weatherData);

            // create the readings
            WeatherMeasurements readings = new WeatherMeasurements();

            readings.Temperature = 80f;
            readings.Humidity    = 65f;
            readings.Pressure    = 30.4f;

            weatherData.Mesurements(readings);

            readings.Temperature = 82f;
            readings.Humidity    = 70f;
            readings.Pressure    = 29.2f;
            weatherData.Mesurements(readings);

            readings.Temperature = 78f;
            readings.Humidity    = 90f;
            weatherData.Mesurements(readings);
        }
Exemplo n.º 3
0
        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);
        }
Exemplo n.º 4
0
        private static void WeatherStation()
        {
            var weatherData       = new Weatherdata();
            var currentDisplay    = new CurrentConditionDisplay(weatherData);
            var statisticsDisplay = new StatisticsDisplay(weatherData);
            var forcastDisplay    = new ForecastDisplay(weatherData);

            weatherData.SetMeasurements(80, 65, 30.4f);
            weatherData.SetMeasurements(82, 70, 29.4f);
            weatherData.SetMeasurements(78, 80, 29.2f);
        }
Exemplo n.º 5
0
        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();
        }
Exemplo n.º 6
0
        static void Main(string[] args)
        {
            WeatherData weatherData = new WeatherData();

            CurrentConditionDisplay currentDisplay    = new CurrentConditionDisplay(weatherData);
            StatisticsDisplay       statisticsDisplay = new StatisticsDisplay(weatherData);
            ForecastDisplay         forecastDisplay   = new ForecastDisplay(weatherData);

            weatherData.setMeasurements(80, 65, 30.4f);
            weatherData.setMeasurements(82, 70, 29.9f);
            weatherData.setMeasurements(78, 90, 29.2f);
            Console.Read();
        }
Exemplo n.º 7
0
        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);
        }
Exemplo n.º 8
0
        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);
        }
Exemplo n.º 9
0
        static void Main(string[] args)
        {
            WeatherData      weatherData      = new WeatherData();
            ForecastDisplay  forecastDisplay  = new ForecastDisplay(weatherData);
            HeatIndexDisplay heatIndexDisplay = new HeatIndexDisplay(weatherData);

            //weatherData.registerObserver(forecastDisplay);
            //weatherData.registerObserver(heatIndexDisplay);


            weatherData.setMeasurements(80, 65, 30.4f);
            weatherData.setMeasurements(82, 70, 29.2f);
            weatherData.setMeasurements(78, 90, 29.2f);
        }
Exemplo n.º 10
0
        static void Main(string[] args)
        {
            // create subject weather data to get updated from the weather station
            WeatherData weatherData = new WeatherData();

            // create three differenet display observers
            CurrentConditionsDisplay currentDisplay    = new CurrentConditionsDisplay(weatherData);
            StatisticsDisplay        statisticsDisplay = new StatisticsDisplay(weatherData);
            ForecastDisplay          forecastDisplay   = new ForecastDisplay(weatherData);
            HeadIndexDisplay         heatIndexDisplay  = new HeadIndexDisplay(weatherData);

            // simulate new weather measurements
            weatherData.setMeasurements(80, 65, 30.4f);
            weatherData.setMeasurements(82, 70, 29.2f);
            weatherData.setMeasurements(78, 90, 29.2f);
        }
Exemplo n.º 11
0
        /// <summary>
        ///     Esta tecnica, hace uso de las interfaces proveidas por el framework
        ///     <see cref="IObservable{T}" /> <see cref="IObserver{T}" />
        /// </summary>
        private static void TechniqueUsingNet()
        {
            var provider     = new WeatherDataProvider();              //creamos el proveedor
            var currentDisp  = new CurrentConditionsDisplay(provider); //Suscribimos a [Condiciones actuales] al proveedor
            var forecastDisp = new ForecastDisplay(provider);          //Suscribimos a [Prediciones del clima] al proveedor

            provider.SetMeasurements(40, 78, 3);                       //Indicamos al proveedor unas condiciones de clima
            Console.WriteLine();
            provider.SetMeasurements(45, 79, 4);                       //..
            Console.WriteLine();
            provider.SetMeasurements(46, 73, 6);                       //..
            //Remove forecast display
            forecastDisp.Unsubscribe();                                // Desinscribimos a [Prediciones del clima] debido a que éste ya no desea ser notificado
            Console.WriteLine();
            provider.SetMeasurements(36, 53, 8);                       //Comprobamos que al indicar unas nuevas condiciones de clima, el observador [Prediciones del clima] ya no es notificado
            Console.Read();
        }
Exemplo n.º 12
0
        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)
        {
            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
        }
Exemplo n.º 14
0
        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();
        }
Exemplo n.º 15
0
        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);
        }
Exemplo n.º 16
0
 public WeatherData()
 {
     conditionDisplay  = new ConditionDisplay();
     statisticsDisplay = new StatisticsDisplay();
     forecastDisplay   = new ForecastDisplay();
 }
Exemplo n.º 17
0
 private void btForecastDisplay_Click(object sender, RoutedEventArgs e)
 {
     forecastDisplay = new ForecastDisplay(whetherData);
     forecastDisplay.Show();
 }