Example #1
0
        public void Display()
        {
            IView            view   = new CountryView(displayCountry);
            List <ColorList> myList = new List <ColorList>();

            foreach (string color in displayCountry.Colors)
            {
                Enum.TryParse(color, out ColorList myColor);
                myList.Add(myColor);
            }

            if (myList.Count == 2)
            {
                Console.ForegroundColor = (ConsoleColor)myList[0];
                Console.BackgroundColor = (ConsoleColor)myList[1];
                view.Display();
            }
            else if (myList.Count == 3)
            {
                Console.BackgroundColor = (ConsoleColor)myList[0];
                Console.Write($"Name: { displayCountry.Name}\t");
                Console.BackgroundColor = (ConsoleColor)myList[1];
                Console.Write($"Continent: {displayCountry.Continent}\t");
                Console.BackgroundColor = (ConsoleColor)myList[2];
                Console.Write($"Colors: {string.Join(", ", displayCountry.Colors)}");
            }

            Console.ResetColor();
        }
Example #2
0
 public void SelectCountry(string input)
 {//not sure what the best naming convention is for 1 use objects like this
     //I've mostly observed people doing 1/2 letters though
     try
     {
         CountryView cv = new CountryView(CountryDB[int.Parse(input) - 1]);
         cv.Display();
     }
     catch (Exception e)
     {
         Console.WriteLine("That isn't a valid country! Please select a countries index from the list.");
         SelectCountry(Console.ReadLine());
     }
 }
Example #3
0
        public void CountryAction(Country c)
        {
            CountryView cv = new CountryView(c);

            cv.Display();
        }