Пример #1
0
        public static void NavigateMenu(int menuSelection)
        {
            string countryInput;

            switch (menuSelection)
            {
            case 1:
                CountriesTextFile.ReadCountriesFromFile();
                break;

            case 2:
                Console.Write("Enter a country: ");
                countryInput = Console.ReadLine();
                Validator.GetUserCountry(countryInput);
                CountriesTextFile.WriteCountriesToFile(countryInput);
                break;

            case 3:
                break;

            default:
                Console.WriteLine("That menu item doesn't exist.");
                break;
            }
        }
Пример #2
0
        static void Main(string[] args)
        {
            Console.WriteLine("Welcome to the Countries Maintence Application!");


            while (true)
            {
                var userSelectionApp = new CountriesApp();
                var userSelection    = userSelectionApp.PickCountry();

                if (!Validation.SelectionValidation(userSelection))
                {
                    Console.WriteLine("Enter a number 1-3");
                    continue;
                }
                else if (Validation.SelectionValidation(userSelection) && userSelection == "1")
                {
                    CountriesTextFile.WriteCountries();
                    CountriesTextFile.ReadCountries();
                }
                else if (Validation.SelectionValidation(userSelection) && userSelection == "2")
                {
                    CountriesTextFile.AddCountry();
                }
                else if (Validation.SelectionValidation(userSelection) && userSelection == "3")
                {
                    break;
                }
            }

            Console.ReadKey();
        }
Пример #3
0
        static void Main(string[] args)
        {
            var directoryPath = CountriesTextFile.CheckCountriesTextFile();

            CountriesApp.Greeting();
            bool keepGoing = true;

            while (keepGoing)
            {
                int choice = CountriesApp.GetUserChoice();

                if (choice == 1)
                {
                    CountriesTextFile.ReadCountries(directoryPath);
                }
                else if (choice == 2)
                {
                    string country = "";
                    Console.Write("Enter country: ");
                    country = Validator.CountryChoice();

                    CountriesTextFile.WriteCountries(directoryPath, country);
                    Console.WriteLine("The country has been saved!");
                }
                else if (choice == 3)
                {
                    string country = Validator.CountryInList(directoryPath);
                    CountriesTextFile.DeleteCountry(directoryPath, country);
                    Console.WriteLine("Country deleted!");
                }
                else if (choice == 4)
                {
                    Console.WriteLine("Goodbye!");
                    keepGoing = false;
                }
                else
                {
                    Console.WriteLine("That isn't a valid option, please enter a menu choice.");
                }
            }
            Console.ReadKey();
        }