Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            var weatherFacade = new WeatherFacade();
            var units         = Enum.GetValues(typeof(TemperatureUnit));
            var desiredUnit   = (TemperatureUnit)units.GetValue(_random.Next(units.Length));

            Console.WriteLine($"Desired temperature unit to display: {desiredUnit}");

            var postCodes = new List <string>()
            {
                "10115", "75000", "40404"
            };

            foreach (var postCode in postCodes)
            {
                var temperature = weatherFacade.GetTemperatureForPostcode(postCode, desiredUnit);

                if (temperature != null)
                {
                    Console.WriteLine($"Temperature for location with postcode {postCode} is {temperature}");
                }
                else
                {
                    Console.WriteLine($"Could not find temperature for location with postcode: {postCode}");
                }
            }
        }
Ejemplo n.º 2
0
        static void Main(string[] args)
        {
            const string zipCode = "98074";

            WeatherFacade weatherFacade = new WeatherFacade();

            WeatherFacadeResults results = weatherFacade.GetTempInCity(zipCode);

            Console.WriteLine("The current temperature is {0} F / {1} C in {2}, {3}",
                              results.Fahrenheit, results.Celsius, results.City.Name, results.State.Name);
        }