コード例 #1
0
ファイル: Program.cs プロジェクト: Vgreen2019/Lab-11
        // Methods
        private static void DisplayMovieList(MovieCategories moviecategories, List <string> categories, List <Movies> animatedListInAscOrder, List <Movies> dramaListInAscOrder, List <Movies> horrorListInAscOrder, List <Movies> scifiListInAscOrder, string input)
        {
            bool ignoreCase = true;

            if (Enum.TryParse <MovieTypes>(input, ignoreCase, out MovieTypes result))
            {
                switch (result)
                {
                case MovieTypes.Animated:

                    moviecategories.AnimatedMovies(animatedListInAscOrder);
                    Console.WriteLine("\nDo you want to look at another category?  (Yes/No)");


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

                        if (input1 == "yes" | input1 == "Yes")
                        {
                            Console.Clear();
                            Console.WriteLine("Please choose another category...");
                            DisplayCategoryList(categories);
                        }
                        else if (input1 == "no" | input1 == "No")
                        {
                            ExitApplication();
                        }
                        else
                        {
                            Console.WriteLine("This is not a valid option. Please try again...");
                            continue;
                        }
                        break;
                    }
                    break;

                case MovieTypes.Drama:
                    moviecategories.DramaMovies(dramaListInAscOrder);
                    Console.WriteLine("\nDo you want to look at another category?  (Yes/No)");

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

                        if (input1 == "yes" | input1 == "Yes")
                        {
                            Console.Clear();
                            Console.WriteLine("Please choose another category...");
                            DisplayCategoryList(categories);
                        }
                        else if (input1 == "no" | input1 == "No")
                        {
                            ExitApplication();
                        }
                        else
                        {
                            Console.WriteLine("This is not a valid option. Please try again...");
                            continue;
                        }
                        break;
                    }
                    break;

                case MovieTypes.Horror:

                    moviecategories.HorrorMovies(horrorListInAscOrder);
                    Console.WriteLine("\nDo you want to look at another category?  (Yes/No)");

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

                        if (input1 == "yes" | input1 == "Yes")
                        {
                            Console.Clear();
                            Console.WriteLine("Please choose another category...");
                            DisplayCategoryList(categories);
                        }
                        else if (input1 == "no" | input1 == "No")
                        {
                            ExitApplication();
                        }
                        else
                        {
                            Console.WriteLine("This is not a valid option. Please try again...");
                            continue;
                        }
                        break;
                    }
                    break;


                case MovieTypes.SciFi:
                    moviecategories.ScifiMovies(scifiListInAscOrder);
                    Console.WriteLine("\nDo you want to look at another category?  (Yes/No)");

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

                        if (input1 == "yes" | input1 == "Yes")
                        {
                            Console.Clear();
                            Console.WriteLine("Please choose another category...");
                            DisplayCategoryList(categories);
                        }
                        else if (input1 == "no" | input1 == "No")
                        {
                            ExitApplication();
                        }
                        else
                        {
                            Console.WriteLine("This is not a valid option. Please try again...");
                            continue;
                        }
                        break;
                    }
                    break;


                default:
                    Console.Clear();
                    Console.WriteLine("That category doesn’t exist. Try again. ");

                    DisplayCategoryList(categories);
                    break;
                }
            }
            else
            {
                Console.Clear();
                Console.WriteLine("That category doesn’t exist. Try again. ");

                DisplayCategoryList(categories);
            }
        }