Ejemplo n.º 1
0
        public void CountryMenu()
        {
            Console.WriteLine("What Continent Would you like to learn about?");
            Console.WriteLine("asia");
            Console.WriteLine("north america");
            string         input     = Console.ReadLine();
            List <Country> countries = new List <Country>();

            if (input.ToLower() == "north america")
            {
                NorthAmericaDB nadb = new NorthAmericaDB();
                countries = nadb.Countries;
            }
            else if (input.ToLower() == "asia")
            {
                AsiaDB aDb = new AsiaDB();
                countries = aDb.Countries;
            }

            int             index = 0;
            CountryMenuView menu  = new CountryMenuView(countries);

            menu.Display();
            Country c;

            try
            {
                index = int.Parse(Console.ReadLine());
                c     = countries[index];
                if (index < 0 || index > countries.Count)
                {
                    throw new IndexOutOfRangeException();
                }
            }
            catch (IndexOutOfRangeException e)
            {
                Console.WriteLine(e.StackTrace);
                Console.WriteLine("Index is out of range, it has been set to 0");
                c = countries[0];
            }
            catch (ArgumentOutOfRangeException e)
            {
                Console.WriteLine(e.StackTrace);
                Console.WriteLine("Index is out of range, it has been set to 0");
                c = countries[0];
            }

            CountryDetails(c);
        }
Ejemplo n.º 2
0
        public static void CountryMenu()
        {
            bool runthis = true;

            while (runthis)
            {
                List <Country> countries;
                List <string>  countryNames = new List <string>();
                string         input        = CountryMenuView.UserPick();
                if (input.ToLower() == "north america")
                {
                    NorthAmericaDB nadb = new NorthAmericaDB();
                    countries = nadb.Countries;
                    foreach (Country item in countries)
                    {
                        countryNames.Add(item.Name);
                        Console.WriteLine(item.Name);
                    }
                    Console.WriteLine("what coutry would you like ot learn about?");
                    string input2 = Console.ReadLine();
                    if (input2.ToLower() == "usa")
                    {
                        foreach (Country c in countries)
                        {
                            if (c.Name.ToLower() == input2)
                            {
                                CountryDetails cc = new CountryDetails(c);
                                cc.Display();
                            }
                        }
                    }
                    else if (input2.ToLower() == "mexico")
                    {
                        foreach (Country c in countries)
                        {
                            if (c.Name.ToLower() == input2)
                            {
                                CountryDetails cc = new CountryDetails(c);
                                cc.Display();
                            }
                        }
                    }
                    else if (input2.ToLower() == "Canada")
                    {
                        foreach (Country c in countries)
                        {
                            if (c.Name.ToLower() == input2)
                            {
                                CountryDetails cc = new CountryDetails(c);
                                cc.Display();
                            }
                        }
                    }
                    break;
                }
                else if (input.ToLower() == "asia")
                {
                    AsiaDB adb = new AsiaDB();
                    countries = adb.Countries;
                    foreach (Country c in countries)
                    {
                        countryNames.Add(c.Name);
                        Console.WriteLine(c.Name);
                    }
                    Console.WriteLine("what coutry would you like ot learn about?");
                    string input2 = Console.ReadLine();
                    if (input2.ToLower() == "vietnam")
                    {
                        foreach (Country c in countries)
                        {
                            if (c.Name.ToLower() == input2)
                            {
                                CountryDetails cc = new CountryDetails(c);
                                cc.Display();
                            }
                        }
                    }
                    else if (input2.ToLower() == "japan")
                    {
                        foreach (Country c in countries)
                        {
                            if (c.Name.ToLower() == input2)
                            {
                                CountryDetails cc = new CountryDetails(c);
                                cc.Display();
                            }
                        }
                    }
                    else if (input2.ToLower() == "north korea")
                    {
                        foreach (Country c in countries)
                        {
                            if (c.Name.ToLower() == input2)
                            {
                                CountryDetails cc = new CountryDetails(c);
                                cc.Display();
                            }
                        }
                    }
                    else if (input2.ToLower() == "south korea")
                    {
                        foreach (Country c in countries)
                        {
                            if (c.Name.ToLower() == input2)
                            {
                                CountryDetails cc = new CountryDetails(c);
                                cc.Display();
                            }
                        }
                    }
                    break;
                }
                else
                {
                    continue;
                }
            }
        }
Ejemplo n.º 3
0
        public void CountryMenu()
        {
            bool run = true;

            while (run == true)
            {
                List <string>  countryNames = new List <string>();
                List <Country> countries;
                string         input = CountryMenuView.CountryPick();
                if (input.ToLower() == "north america")
                {
                    NorthAmericaDB nadb = new NorthAmericaDB();
                    countries = nadb.Countries;
                    foreach (Country c in countries)
                    {
                        countryNames.Add(c.Name);
                        Console.WriteLine(c.Name);
                    }

                    string input2 = CountryMenuView.CountrySelect();
                    if (input2.ToLower() == "usa")
                    {
                        foreach (Country c in countries)
                        {
                            if (c.Name.ToLower() == input2)
                            {
                                CountryDetails cc = new CountryDetails(c);
                                cc.Display();
                            }
                        }
                    }
                    else if (input2.ToLower() == "mexico")
                    {
                        foreach (Country c in countries)
                        {
                            if (c.Name.ToLower() == input2)
                            {
                                CountryDetails cc = new CountryDetails(c);
                                cc.Display();
                            }
                        }
                    }
                    else if (input2.ToLower() == "canada")
                    {
                        foreach (Country c in countries)
                        {
                            if (c.Name.ToLower() == input2)
                            {
                                CountryDetails cc = new CountryDetails(c);
                                cc.Display();
                            }
                        }
                    }
                }
                if (input.ToLower() == "asia")
                {
                    AsiaDB adb = new AsiaDB();
                    countries = adb.Countries;
                    foreach (Country c in countries)
                    {
                        countryNames.Add(c.Name);
                        Console.WriteLine(c.Name);
                    }

                    string input2 = CountryMenuView.CountrySelect();
                    if (input2.ToLower() == "china")
                    {
                        foreach (Country c in countries)
                        {
                            if (c.Name.ToLower() == input2)
                            {
                                CountryDetails cc = new CountryDetails(c);
                                cc.Display();
                            }
                        }
                    }
                    else if (input2.ToLower() == "japan")
                    {
                        foreach (Country c in countries)
                        {
                            if (c.Name.ToLower() == input2)
                            {
                                CountryDetails cc = new CountryDetails(c);
                                cc.Display();
                            }
                        }
                    }
                    else if (input2.ToLower() == "vietnam")
                    {
                        foreach (Country c in countries)
                        {
                            if (c.Name.ToLower() == input2)
                            {
                                CountryDetails cc = new CountryDetails(c);
                                cc.Display();
                            }
                        }
                    }
                    else if (input2.ToLower() == "north korea")
                    {
                        foreach (Country c in countries)
                        {
                            if (c.Name.ToLower() == input2)
                            {
                                CountryDetails cc = new CountryDetails(c);
                                cc.Display();
                            }
                        }
                    }
                    else if (input2.ToLower() == "south korea")
                    {
                        foreach (Country c in countries)
                        {
                            if (c.Name.ToLower() == input2)
                            {
                                CountryDetails cc = new CountryDetails(c);
                                cc.Display();
                            }
                        }
                    }
                }
                run = Continue();
            }
        }