Beispiel #1
0
        static void Main(string[] args)
        {
            string CodeName;
            IWeatherDataService service;

            //we used try and catch to demonstrate if the method
            //GetWeatherDataService (in WeatherDataServiceFactory) had been called with valid number
            //the number should choose the method of the service
            // in our case there is only one service OpenWeahterMap
            try
            {
                //calling the method with invalid number
                //for catching this error
                service = WeatherDataServiceFactory.GetWeatherDataService(3);
            }
            catch (WeatherDataServiceException ex)
            {
                Console.WriteLine(ex + "\nusing OPEN_WEATHER_MAP service for program continue to work");
                //next line is equal to:
                //service = OpenWeatherMap.Instance
                service = WeatherDataServiceFactory.GetWeatherDataService(WeatherDataServiceFactory.OPEN_WEATHER_MAP);
            }
            while (true)
            {
                Console.WriteLine("Please enter the city or Exit to exit...");
                CodeName = Console.ReadLine();
                if (CodeName.Equals("Exit") || CodeName.Equals("exit") || CodeName.Equals("EXIST"))
                {
                    break;
                }
                service.GetWeatherData(new Location(CodeName));
                if (service.GetWD() == null)
                {
                    continue;
                }
                Console.Clear();
                Console.WriteLine("Hey Sir, You requested to see the weather in {0} in country {1}", service.GetWD().cityName, service.GetWD().country);
                Console.WriteLine("Or to be more specific it's in coord {0} , {1} ", service.GetWD().coordLat, service.GetWD().coordLon);
                Console.WriteLine("The last update I have is from {0}", service.GetWD().lastupdate);
                Console.WriteLine("It seems to be {0} today ", service.GetWD().weather);
                Console.WriteLine("The sun will rise at {0} and set at {1}", service.GetWD().sunRise, service.GetWD().sunSet);
                Console.WriteLine("the tempature now is {0} and it should be between {1} - {2}", service.GetWD().tempature, service.GetWD().tempatureMin, service.GetWD().tempatureMax);
                Console.WriteLine("the wind speed is {0} MPH", service.GetWD().windSpeed);
                Console.WriteLine("the pressure is {0} hPa", service.GetWD().pressure);
                Console.WriteLine("cloud status is {0} and that's great", service.GetWD().clouds);
                Console.WriteLine("the humidity is {0}% \n\n", service.GetWD().humidity);
                service.ClearWeatherData();
            }

            Console.WriteLine("Copyrights Shenkar - Software Engineering");
            Console.WriteLine("Course Programming Languages Oct 2016 - By Mr. Life Michael ");
            Console.WriteLine("Written by Yogev Heskia and Nir Mekin ");
        }
Beispiel #2
0
        /// <summary>
        /// Returns true if LookupList instances are equal
        /// </summary>
        /// <param name="other">Instance of LookupList to be compared</param>
        /// <returns>Boolean</returns>
        public bool Equals(LookupList other)
        {
            if (other is null)
            {
                return(false);
            }
            if (ReferenceEquals(this, other))
            {
                return(true);
            }

            return
                ((
                     Id == other.Id ||
                     Id.Equals(other.Id)
                     ) &&
                 (
                     ContextName == other.ContextName ||
                     ContextName != null &&
                     ContextName.Equals(other.ContextName)
                 ) &&
                 (
                     IsDefault == other.IsDefault ||
                     IsDefault.Equals(other.IsDefault)
                 ) &&
                 (
                     CodeName == other.CodeName ||
                     CodeName != null &&
                     CodeName.Equals(other.CodeName)
                 ) &&
                 (
                     Value == other.Value ||
                     Value != null &&
                     Value.Equals(other.Value)
                 ) &&
                 (
                     DisplaySortOrder == other.DisplaySortOrder ||
                     DisplaySortOrder != null &&
                     DisplaySortOrder.Equals(other.DisplaySortOrder)
                 ));
        }