public void WelcomeAction()
        {
            CountryListView countries = new CountryListView(CountryDb);

            while (true)
            {
                Console.WriteLine();
                countries.Display();

                Console.Write("Hello welcome to the country app. Please select a country from the following list by number: ");

                string answer = Console.ReadLine();

                try
                {
                    int index = int.Parse(answer);
                    Console.WriteLine();
                    CountryAction(CountryDb[index - 1]);
                    Console.WriteLine();
                    break;
                }
                catch (FormatException)
                {
                    Console.WriteLine();
                    Console.WriteLine("That is not a valid number. Please enter a corresponding number, not a letter or character. ");
                }
                catch (ArgumentOutOfRangeException)
                {
                    Console.WriteLine();
                    Console.WriteLine("That number did not correspond to a country. Please enter a valid number. ");
                }
            }
        }
Пример #2
0
        public void WelcomeAction()
        {
            bool run = true;

            Console.WriteLine("Hello! Welcome to the country app!");
            while (run)
            {
                Console.WriteLine("Would you like to select a country? Enter y to start or any other key twice to exit.");
                string response = Console.ReadLine().ToLower();
                if (response == "y")
                {
                    CountryDataBase countryDataBase = new CountryDataBase();
                    CountryListView countryListView = new CountryListView(countryDataBase.Countries);
                    Console.WriteLine("Please select a country from the following list: ");
                    countryListView.Display();

                    int selection = int.Parse(Console.ReadLine());
                    CountryAction(countryDataBase.Countries[selection]);
                }
                else
                {
                    return;
                }
            }
        }
Пример #3
0
        public void WelcomeAction()
        {
            string response = "yes";


            CountryListView listView = new CountryListView(countryDb);

            Console.WriteLine("Hello, welcome to the country app.");

            while (response == "yes")
            {
                Console.WriteLine("Please select a country from the following list: ");
                listView.Display();

                string selection = isValid(countryDb.Count);

                for (int i = 0; i < countryDb.Count; i++)
                {
                    if (selection == i.ToString())
                    {
                        CountryAction(countryDb[i]);
                    }
                }

                Console.WriteLine("\nWould you like to learn about another Country? (yes/no)");
                response = Console.ReadLine().ToLower();
                Console.Clear();
            }
            Console.WriteLine("\nThank you!");
        }
Пример #4
0
        public void WelcomeAction()
        {
            CountryListView clv = new CountryListView(CountryDb);

            Console.WriteLine("Hello, welcome to the country app. Please select a country from the following list:");

            clv.Display();

            Console.WriteLine("Please select a country:");

            while (true)
            {
                string input = Console.ReadLine();

                Console.WriteLine();

                int index = 0;

                bool isNum = int.TryParse(input, out index);

                string again = "";

                if (isNum)
                {
                    try
                    {
                        CountryAction(CountryDb[index - 1]);

                        Console.WriteLine();

                        Console.WriteLine("Would you like to learn about another country? y for yes, anything else to exit:");

                        again = Console.ReadLine();
                    }
                    catch
                    {
                        Console.WriteLine("Plase enter a valid country index:");
                        continue;
                    }
                }
                else
                {
                    Console.WriteLine("Plase enter a valid country index:");
                    continue;
                }


                if (again == "y")
                {
                    Console.Clear();
                    WelcomeAction();
                }
                else
                {
                    Console.WriteLine("Goodbye!");
                    break;
                }
                break;
            }
        }
Пример #5
0
        public void WelcomeAction()
        {
            CountryListView countryList = new CountryListView(CountryDb);

            Console.Clear();
            Console.WriteLine("Hello, welcome to the country app. " +
                              "Please select a country from the following list:");
            countryList.Display();
            CountryAction(SelectCountry(countryList));
            WelcomeSelect();
        }
Пример #6
0
        public void SecondAction()
        {
            CountryListView countries = new CountryListView(CountryDb);

            countries.Display();
            Console.Write("Please select a country from the above list: ");
            string answer = Console.ReadLine();
            int    index  = int.Parse(answer);

            Console.WriteLine();
            CountryAction(CountryDb[index]);
            Console.WriteLine();
        }
Пример #7
0
        public void WelcomeAction()
        {
            CountryListView countryListView = new CountryListView(CountryDb);

            Console.WriteLine("Hi! Please select a country...");

            countryListView.Display();

            int userSelection = int.Parse(Console.ReadLine());

            Country country = CountryDb[userSelection];

            CountryAction(country);
        }
Пример #8
0
        public Country SelectCountry(CountryListView countryList)
        {
            int i;

            Console.WriteLine("Type the corresponding number of a country.");
            while (!Int32.TryParse(Console.ReadLine(), out i) ||
                   i - 1 > countryList.Countries.Count() || i - 1 < 0)
            {
                Console.Clear();
                Console.WriteLine("That was not a valid input.");
                Console.WriteLine("Type the corresponding number of a country.");
                countryList.Display();
            }
            return(countryList.Countries[i - 1]);
        }
Пример #9
0
        static void Main(string[] args)
        {
            List <Country> countries = new List <Country>();

            #region Countries in 'countries'
            Country c1 = new Country("United States", "North America", new List <string> {
                "Red", "White", "Blue"
            });
            countries.Add(c1);

            Country c2 = new Country("Algeria", "Africa", new List <string> {
                "Green", "White", "Red"
            });
            countries.Add(c2);

            Country c3 = new Country("Angola", "Africa", new List <string> {
                "Red", "White", "Blue"
            });
            countries.Add(c3);

            Country c4 = new Country("Benin", "Africa", new List <string> {
                "Green", "Yellow", "Red"
            });
            countries.Add(c4);

            Country c5 = new Country("Botswana", "Africa", new List <string> {
                "Light Blue", "Black", "White"
            });
            countries.Add(c5);

            Country c6 = new Country("Kenya", "Africa", new List <string> {
                "Black", "Red", "Green", "White"
            });
            countries.Add(c6);

            Country c7 = new Country("Libya", "Africa", new List <string> {
                "Red", "Black", "Green", "White"
            });
            countries.Add(c7);

            Country c8 = new Country("Madagascar", "Africa", new List <string> {
                "Red", "Green", "White"
            });
            countries.Add(c8);

            Country c9 = new Country("Antiqua and Barbuda", "North America", new List <string> {
                "Red", "White", "Blue", "Black", "Yellow"
            });
            countries.Add(c9);

            Country c10 = new Country("Montserrat", "North America", new List <string> {
                "Black", "Green", "Dark Blue", "Red", "White"
            });
            countries.Add(c10);

            Country c11 = new Country("France", "Europe", new List <string> {
                "Blue", "White", "Red"
            });
            countries.Add(c11);

            Country c12 = new Country("Italy", "Europe", new List <string> {
                "Green", "White", "Red"
            });
            countries.Add(c12);
            #endregion

            CountryController controller = new CountryController();
            controller.CountryDb = countries;

            CountryListView listView = new CountryListView(countries);

            controller.WelcomeAction();
        }