Exemplo n.º 1
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;
                }
            }
        }
Exemplo n.º 2
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!");
        }
        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. ");
                }
            }
        }
Exemplo n.º 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;
            }
        }
Exemplo n.º 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();
        }
Exemplo n.º 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();
        }
Exemplo n.º 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);
        }
Exemplo n.º 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]);
        }