예제 #1
0
        static void Main(string[] args)
        {
            /*
             *
             * do
             * {
             * line = input.ReadLine();
             *
             * if (line == null)
             * {
             * return;
             * }
             *
             * if (line == String.Empty)
             * {
             * continue;
             * }
             *
             * // Here you process the non-empty line
             *
             * } while (true);
             */

            var cityWeatherBase = new WeatherBase();

            //int key;
            //string line;

            // cityWeatherBase.CitiesWeather.Add(cityWeatherBase.AddDataToBase("Olawa"));
            // cityWeatherBase.SaveChanges();
            // cityWeatherBase.ShowDataBaseContent();



            do
            {
                Console.Clear();
                Console.WriteLine("1. Add new city");
                Console.WriteLine("2. Clear whole database");
                Console.WriteLine("3. Show whole content");
                Console.WriteLine("4. Remove last added element");
                Console.WriteLine("5. Find elements by temperature");
                Console.WriteLine("6. Find elements by wind speed");
                Console.WriteLine("7. Menu");
                Console.WriteLine("8. Exit");
                Console.WriteLine("Chose one option");
            } while (MainMenu(cityWeatherBase));
            //while (MainMenu((int)Convert.ToDecimal(Console.ReadLine()), cityWeatherBase));
            //{
            //    Console.Clear();
            //    MainMenu(7, cityWeatherBase);
            //}
        }
예제 #2
0
        static bool MainMenu(WeatherBase cityWeatherBase)
        {
            switch (Console.ReadLine())
            {
            case "0":
                return(true);

            case "1":
                Console.WriteLine("Insert name of the city:");
                cityWeatherBase.CitiesWeather.Add(cityWeatherBase.AddDataToBase(Console.ReadLine()));
                cityWeatherBase.SaveChanges();
                return(true);

            case "2":
                cityWeatherBase.ClearBase();
                Console.WriteLine("Base Cleared");
                Console.ReadLine();
                return(true);

            case "3":
                cityWeatherBase.ShowDataBaseContent();
                Console.WriteLine("Press enter to return");
                Console.ReadLine();
                return(true);

            case "7":
                Console.Clear();
                Console.WriteLine("1. Add new city");
                Console.WriteLine("2. Clear whole database");
                Console.WriteLine("3. Show whole content");
                Console.WriteLine("4. Remove last added element");
                Console.WriteLine("5. Find elements by temperature");
                Console.WriteLine("6. Find elements by wind speed");
                Console.WriteLine("7. Menu");
                Console.WriteLine("8. Exit");
                Console.WriteLine("Chose one option");
                return(true);

            case "4":
                cityWeatherBase.RemoveLast();
                Console.WriteLine("Element removed");
                Console.WriteLine("Press enter to return");
                Console.ReadLine();
                return(true);

            case "5":
                Console.WriteLine("Insert the temperature: ");
                cityWeatherBase.FindByTemp(Convert.ToInt32(Console.ReadLine()));

                Console.WriteLine("Press enter to return");
                Console.ReadLine();
                return(true);

            case "6":
                Console.WriteLine("Insert the wind speed: ");
                cityWeatherBase.FindByWindSpeed(Convert.ToInt32(Console.ReadLine()));
                Console.WriteLine("Press enter to return");
                Console.ReadLine();
                return(true);

            case "8":
                return(false);

            default:
                Console.WriteLine("Error: option not found");
                Console.WriteLine("\nPress enter to return");
                Console.ReadLine();
                return(true);
            }
        }