예제 #1
0
        public static void GuestsMenuEnjoy()
        {
            GuestHeading();

            MainScreen.ChangeColorToBlue();
            Console.WriteLine("  What would you like to do now?\n");
            Thread.Sleep(500);
            MainScreen.ChangeColorToRed();
            Console.WriteLine("\t1. Choose another movie\n" +
                              "\t2. Go back to the main menu");
            Console.Write("  > ");
            int menuType = 0;

            Console.ForegroundColor = ConsoleColor.Gray;
            string userInput = Console.ReadLine();

            try
            {
                CustomException.ValidateInput(Convert.ToInt32(userInput), menuType);
            }
            catch (CustomException)
            {
                GuestsMenuEnjoy();
            }
            catch (OverflowException)
            {
                CustomException.OverflowErrorMessage();
                GuestsMenuEnjoy();
            }
            catch (FormatException)
            {
                CustomException.FormatErrorMessage();
                GuestsMenuEnjoy();
            }
            switch (userInput)
            {
            case "1":
                Console.Clear();
                GuestsMenu();
                break;

            case "2":
                MainScreen.ChangeColorToDarkGray();
                Console.WriteLine("\n  Taking you back to Main Screen.");
                MainScreen.ChangeColorToRed();
                Thread.Sleep(1000);
                MainScreen.Loading(150);
                MainScreen.MainMenu();
                break;

            default:
                break;
            }
        }
예제 #2
0
        private static void AdminMenuMoviesPlayingToday()
        {
            AdminHeading();

            MainScreen.ChangeColorToDarkYellow();
            Console.WriteLine("  Welcome MoviePlex Administrator.\n\n");
            MainScreen.ChangeColorToBlue();
            Console.Write("  How many movies are playing today?");
            MainScreen.ChangeColorToDarkGray();
            Console.WriteLine(" (Maximum 10)");
            MainScreen.ChangeColorToBlue();
            Console.Write("  > ");
            int menuType = 2;

            Console.ForegroundColor = ConsoleColor.Gray;
            string userInput = Console.ReadLine();

            if (userInput == "")
            {
                CustomException.NoInputDetected();
                AdminMenuMoviesPlayingToday();
            }

            try
            {
                CustomException.ValidateInput(Convert.ToInt32(userInput), menuType);
            }
            catch (CustomException)
            {
                AdminMenuMoviesPlayingToday();
            }
            catch (OverflowException)
            {
                CustomException.OverflowErrorMessage();
                AdminMenuMoviesPlayingToday();
            }
            catch (FormatException)
            {
                CustomException.FormatErrorMessage();
                AdminMenuMoviesPlayingToday();
            }
            switch (userInput)
            {
            default:
                playingToday = Convert.ToInt32(userInput);
                Thread.Sleep(500);
                AdminMenuAddMovies();
                break;
            }
        }
예제 #3
0
        public static void GuestsMenu()
        {
            GuestHeading();

            if (Admin.moviesList.Count == 0)
            {
                MainScreen.ChangeColorToDarkYellow();
                Console.WriteLine("  Sorry, there are no movies playing today.");
                Thread.Sleep(1000);
                MainScreen.ChangeColorToDarkGray();
                Console.WriteLine("\n  Taking you back to Main Screen.");
                MainScreen.ChangeColorToRed();
                Thread.Sleep(1000);
                MainScreen.Loading(150);
                MainScreen.MainMenu();
            }
            else
            {
                MainScreen.ChangeColorToBlue();
                Console.WriteLine("  Welcome!! Movies to be Played Today:");
                int count = 1;
                MainScreen.ChangeColorToDarkGray();
                Console.WriteLine("\t<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<");
                Console.Write("\t|  ");
                MainScreen.ChangeColorToRed();
                Console.Write("Sr.  ");
                MainScreen.ChangeColorToDarkGray();
                Console.Write("|                     ");
                MainScreen.ChangeColorToRed();
                Console.Write("Title                       ");
                MainScreen.ChangeColorToDarkGray();
                Console.Write("|     ");
                MainScreen.ChangeColorToRed();
                Console.Write("Rating");
                MainScreen.ChangeColorToDarkGray();
                Console.WriteLine("      |");
                foreach (KeyValuePair <string, string> movie in Admin.moviesList)
                {
                    Console.WriteLine("\t-----------------------------------------------------------------------------");
                    Console.Write("\t|   ");
                    MainScreen.ChangeColorToBlue();
                    Console.Write("{0}", count++);
                    MainScreen.ChangeColorToDarkGray();
                    Console.Write("   |");
                    MainScreen.ChangeColorToRed();
                    Console.Write("  {0}", movie.Key);
                    MainScreen.ChangeColorToDarkGray();
                    Console.Write(new String(' ', (47 - movie.Key.Length)));
                    Console.Write("|");
                    Console.Write(new String(' ', (17 - movie.Value.Length) / 2));
                    MainScreen.ChangeColorToRed();
                    Console.Write("{0}", movie.Value);
                    Console.Write(new String(' ', (18 - movie.Value.Length) / 2));
                    MainScreen.ChangeColorToDarkGray();
                    Console.Write("|\n");
                }
                Console.WriteLine("\t>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>");

                MainScreen.ChangeColorToBlue();
                Console.WriteLine("\n\n  Which movie would you like to watch?");
                MainScreen.ChangeColorToRed();
                Console.Write("  > ");
                Console.ForegroundColor = ConsoleColor.Gray;
                string userInput = Console.ReadLine();

                if (userInput == "")
                {
                    CustomException.NoInputDetected();
                    GuestsMenu();
                }

                try
                {
                    CustomException.ValidateMovieChoice(Convert.ToInt32(userInput));
                }
                catch (CustomException)
                {
                    GuestsMenu();
                }
                catch (OverflowException)
                {
                    CustomException.OverflowErrorMessage();
                    GuestsMenu();
                }
                catch (FormatException)
                {
                    CustomException.FormatErrorMessage();
                    GuestsMenu();
                }
                switch (userInput)
                {
                default:
                    movieChoice = Convert.ToInt32(userInput);
                    GuestsMenuVerifyAge();
                    break;
                }
            }
        }
예제 #4
0
        public static void GuestsMenuVerifyAge()
        {
            GuestHeading();

            MainScreen.ChangeColorToRed();
            Console.Write("\n  You have chosen to watch :");
            MainScreen.ChangeColorToDarkYellow();
            Console.WriteLine(" {0}", Admin.moviesList[movieChoice - 1].Key);
            MainScreen.ChangeColorToRed();
            Console.Write("  It has the rating of :");
            MainScreen.ChangeColorToDarkYellow();
            Console.WriteLine(" {0}", Admin.moviesList[movieChoice - 1].Value);

            MainScreen.ChangeColorToBlue();
            Console.WriteLine("\n\n  What is your age?");
            MainScreen.ChangeColorToRed();
            Console.Write("  > ");
            Console.ForegroundColor = ConsoleColor.Gray;
            guestAge = Console.ReadLine();

            int ageLimit = 0;

            if (Admin.moviesList[movieChoice - 1].Value == "G")
            {
                ageLimit = 0;
            }
            else if (Admin.moviesList[movieChoice - 1].Value == "PG")
            {
                ageLimit = 10;
            }
            else if (Admin.moviesList[movieChoice - 1].Value == "PG-13")
            {
                ageLimit = 13;
            }
            else if (Admin.moviesList[movieChoice - 1].Value == "R")
            {
                ageLimit = 15;
            }
            else if (Admin.moviesList[movieChoice - 1].Value == "NC-17")
            {
                ageLimit = 17;
            }
            else
            {
                ageLimit = Convert.ToInt32(Admin.moviesList[movieChoice - 1].Value);
            }
            try
            {
                CustomException.ValidateGuestAge(Convert.ToInt32(guestAge), ageLimit);
            }
            catch (CustomException)
            {
                GuestsMenuVerifyAge();
            }
            catch (OverflowException)
            {
                CustomException.OverflowErrorMessage();
                GuestsMenuVerifyAge();
            }
            catch (FormatException)
            {
                CustomException.FormatErrorMessage();
                GuestsMenuVerifyAge();
            }
            switch (guestAge)
            {
            default:
                LoadingMovie();
                break;
            }
        }
예제 #5
0
        public static bool UserInput(string userInput)
        {
            int menuType = 0;

            userInput = userInput.ToLower();

            switch (userInput)
            {
            case "1":
            case "admin":
            case "administrator":
            {
                ChangeColorToDarkYellow();
                Loading(150);
                Admin adminObj = new Admin();
                ChangeColorToGray();
                Admin.AdminMenu();
                return(false);
            }

            case "2":
            case "guest":
            {
                ChangeColorToDarkYellow();
                Loading(150);
                ChangeColorToGray();
                Guests.GuestsMenu();
                return(false);
            }

            default:
            {
                if (userInput.Equals(""))
                {
                    CustomException.NoInputDetected();
                    MainMenu();
                }
                else if (userInput.Contains("ad") || userInput.Contains("adm") || userInput.Contains("gu") || userInput.Contains("gue"))
                {
                    ChangeColorToDarkYellow();
                    Console.WriteLine("  You made a mistake in spelling.");
                    TryAgain();
                }
                else
                {
                    try
                    {
                        CustomException.ValidateInput(Convert.ToInt32(userInput), menuType);
                    }
                    catch (CustomException)
                    {
                    }
                    catch (OverflowException)
                    {
                        CustomException.OverflowErrorMessage();
                    }
                    catch (FormatException)
                    {
                        CustomException.FormatErrorMessage();
                    }
                }
                MainMenu();
                return(true);
            }
            }
        }
예제 #6
0
        private static void AdminMenuSatisfied()
        {
            AdminHeading();
            MainScreen.ChangeColorToDarkYellow();
            Console.WriteLine("  Movies to be Played Today:");
            int count = 1;

            MainScreen.ChangeColorToDarkGray();
            Console.WriteLine("\t<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<");
            Console.Write("\t|  ");
            MainScreen.ChangeColorToBlue();
            Console.Write("Sr.  ");
            MainScreen.ChangeColorToDarkGray();
            Console.Write("|                     ");
            MainScreen.ChangeColorToBlue();
            Console.Write("Title                       ");
            MainScreen.ChangeColorToDarkGray();
            Console.Write("|     ");
            MainScreen.ChangeColorToBlue();
            Console.Write("Rating");
            MainScreen.ChangeColorToDarkGray();
            Console.WriteLine("      |");
            foreach (KeyValuePair <string, string> movie in moviesList)
            {
                Console.WriteLine("\t-----------------------------------------------------------------------------");
                Console.Write("\t|   ");
                MainScreen.ChangeColorToDarkYellow();
                Console.Write("{0}", count++);
                MainScreen.ChangeColorToDarkGray();
                Console.Write("   |");
                MainScreen.ChangeColorToBlue();
                Console.Write("  {0}", movie.Key);
                MainScreen.ChangeColorToDarkGray();
                Console.Write(new String(' ', (47 - movie.Key.Length)));
                Console.Write("|");
                Console.Write(new String(' ', (17 - movie.Value.Length) / 2));
                MainScreen.ChangeColorToBlue();
                Console.Write("{0}", movie.Value);
                Console.Write(new String(' ', (18 - movie.Value.Length) / 2));
                MainScreen.ChangeColorToDarkGray();
                Console.Write("|\n");
            }
            Console.WriteLine("\t>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>");

            MainScreen.ChangeColorToBlue();
            Console.Write("\n\n  Your Movies Playing Today Are Listed Above. Are you satisfied");
            MainScreen.ChangeColorToDarkYellow();
            Console.WriteLine(" Y / N ?");
            MainScreen.ChangeColorToBlue();
            Console.Write("  > ");
            Console.ForegroundColor = ConsoleColor.Gray;
            string userInput = Console.ReadLine().ToLower();

            if (userInput == "y" || userInput == "yes" || userInput == "0")
            {
                MainScreen.ChangeColorToDarkYellow();
                Console.WriteLine("\n\n  We will play these movies.   :)");
                Thread.Sleep(1000);
                Console.WriteLine("\n  Taking you back to Main Screen.");
                Thread.Sleep(1000);
                MainScreen.ChangeColorToBlue();
                MainScreen.Loading(150);
                Console.Clear();
                MainScreen.MainMenu();
            }
            else if (userInput == "n" || userInput == "no")
            {
                moviesList.Clear();
                AdminMenuMoviesPlayingToday();
            }
            else if (userInput == "")
            {
                CustomException.NoInputDetected();
                AdminMenuSatisfied();
            }
            else
            {
                Console.Clear();
                MainScreen.ChangeColorToRed();
                Console.WriteLine("  That was not a valid option.");
                MainScreen.TryAgain();
                AdminMenuSatisfied();
            }
        }
예제 #7
0
        public static void AdminMenuAddMovies()
        {
            AdminHeading();
            int    moviesPlayingToday = playingToday;
            string movieName;
            string ratingOrAge;
            Dictionary <int, string> numbers = new Dictionary <int, string>()
            {
                { 1, "First" },
                { 2, "Second" },
                { 3, "Third" },
                { 4, "Fourth" },
                { 5, "Fifth" },
                { 6, "Sixth" },
                { 7, "Seventh" },
                { 8, "Eighth" },
                { 9, "Ninth" },
                { 10, "Tenth" },
            };

            bool flag = false;

            for (int x = moviesList.Count + 1; x <= moviesPlayingToday; x++)
            {
                Console.WriteLine();
                getMovieName(numbers[x]);
                getMovieRating(numbers[x]);
            }

            void getMovieName(string serialOrder)
            {
                if (moviesList.Count > 0 && flag == true)
                {
                    AdminHeading();
                    flag = false;
                    for (int x = 0; x < moviesList.Count; x++)
                    {
                        MainScreen.ChangeColorToDarkYellow();
                        Console.Write("  Please Enter {0} Movie's Name >", numbers[x + 1]);
                        MainScreen.ChangeColorToDarkCyan();
                        Console.WriteLine(" {0}", moviesList[x].Key);
                        MainScreen.ChangeColorToDarkYellow();
                        Console.Write("  Please Enter the Age Limit OR Rating For the {0} Movie >", numbers[x + 1]);
                        MainScreen.ChangeColorToDarkCyan();
                        Console.WriteLine(" {0}", moviesList[x].Value);
                        Console.WriteLine("");
                    }
                }

                MainScreen.ChangeColorToDarkYellow();
                Console.Write("  Please Enter {0} Movie's Name > ", serialOrder);
                MainScreen.ChangeColorToDarkCyan();
                movieName = Console.ReadLine();
                if (movieName == "0")
                {
                    MainScreen.MainMenu();
                }
                if (movieName == "")
                {
                    CustomException.NoInputDetected();
                    if (moviesList.Count != 0)
                    {
                        flag = true;
                    }
                    else
                    {
                        AdminHeading();
                    }
                    getMovieName(serialOrder);
                }
                movieName = char.ToUpper(movieName[0]) + movieName.Substring(1);
                if ((movieName.Length) % 2 != 0)
                {
                    movieName += " ";
                }
            }

            void getMovieRating(string serialOrder)
            {
                if (flag == false)
                {
                    MainScreen.ChangeColorToDarkYellow();
                    Console.Write("  Please Enter the Age Limit OR Rating For the {0} Movie > ", serialOrder);
                    MainScreen.ChangeColorToDarkCyan();
                    ratingOrAge = Console.ReadLine().ToUpper();

                    switch (ratingOrAge)
                    {
                    case "G":
                    {
                        ratingOrAge = "G";
                        moviesList.Add(new KeyValuePair <string, string>(movieName, ratingOrAge));
                        break;
                    }

                    case "PG":
                    case "10":
                    {
                        ratingOrAge = "PG";
                        moviesList.Add(new KeyValuePair <string, string>(movieName, ratingOrAge));
                        break;
                    }

                    case "PG-13":
                    case "PG 13":
                    case "PG13":
                    case "13":
                    {
                        ratingOrAge = "PG-13";
                        moviesList.Add(new KeyValuePair <string, string>(movieName, ratingOrAge));
                        break;
                    }

                    case "R":
                    case "15":
                    {
                        ratingOrAge = "R";
                        moviesList.Add(new KeyValuePair <string, string>(movieName, ratingOrAge));
                        break;
                    }

                    case "NC-17":
                    case "NC 17":
                    case "NC17":
                    case "17":
                    {
                        ratingOrAge = "NC-17";
                        moviesList.Add(new KeyValuePair <string, string>(movieName, ratingOrAge));
                        break;
                    }

                    default:
                    {
                        try
                        {
                            int  age;
                            bool isInt = int.TryParse(ratingOrAge, out age);
                            if (ratingOrAge == "0")
                            {
                                throw new CustomException("back to main menu");
                            }
                            else if (isInt)
                            {
                                if (age < 0)
                                {
                                    throw new CustomException("negative");
                                }
                                else if (age > 17 && age < 120)
                                {
                                    ratingOrAge = "NC-17";
                                    moviesList.Add(new KeyValuePair <string, string>(movieName, ratingOrAge));
                                }
                                else if (age > 15 && age < 120)
                                {
                                    ratingOrAge = "R";
                                    moviesList.Add(new KeyValuePair <string, string>(movieName, ratingOrAge));
                                }
                                else if (age > 13 && age < 120)
                                {
                                    ratingOrAge = "PG-13";
                                    moviesList.Add(new KeyValuePair <string, string>(movieName, ratingOrAge));
                                }
                                else if (age > 10 && age < 120)
                                {
                                    ratingOrAge = "PG";
                                    moviesList.Add(new KeyValuePair <string, string>(movieName, ratingOrAge));
                                }
                                else if (age > 0 && age < 120)
                                {
                                    ratingOrAge = "G";
                                    moviesList.Add(new KeyValuePair <string, string>(movieName, ratingOrAge));
                                }
                                else if (age > 120)
                                {
                                    throw new CustomException("risky customer");
                                }
                            }
                            else if (!isInt)
                            {
                                if (
                                    ratingOrAge != "G" &&
                                    ratingOrAge != "PG" &&
                                    ratingOrAge != "PG-13" &&
                                    ratingOrAge != "R" &&
                                    ratingOrAge != "NC-17")
                                {
                                    throw new CustomException("invalid movie rating");
                                }
                            }
                        }
                        catch (CustomException)
                        {
                            flag = true;
                            getMovieRating(serialOrder);
                        }
                        break;
                    }
                    }
                }
                else if (moviesList.Count > 0 && flag == true)
                {
                    flag = false;
                    for (int x = 0; x < moviesList.Count; x++)
                    {
                        MainScreen.ChangeColorToDarkYellow();
                        Console.Write("  Please Enter {0} Movie's Name >", numbers[x + 1]);
                        MainScreen.ChangeColorToDarkCyan();
                        Console.WriteLine(" {0}", moviesList[x].Key);
                        MainScreen.ChangeColorToDarkYellow();
                        Console.Write("  Please Enter the Age Limit OR Rating For the {0} Movie >", numbers[x + 1]);
                        MainScreen.ChangeColorToDarkCyan();
                        Console.WriteLine(" {0}", moviesList[x].Value);
                        Console.WriteLine("");
                    }
                    getMovieName(serialOrder);
                    getMovieRating(serialOrder);
                }
                else if (moviesList.Count == 0 && flag == true)
                {
                    flag = false;
                    getMovieName(serialOrder);
                    getMovieRating(serialOrder);
                }
                else if (numbers[moviesList.Count] == serialOrder && flag == true)
                {
                    flag = false;
                    getMovieName(serialOrder);
                    getMovieRating(serialOrder);
                }
            }

            AdminMenuSatisfied();
        }