public CustomException(string errorType) { if (errorType == "back to main menu") { MainScreen.ChangeColorToDarkGray(); Console.WriteLine("\n Taking you back to Main Screen."); Thread.Sleep(1500); MainScreen.MainMenu(); } if (errorType == "out of scope") { Console.Clear(); MainScreen.ChangeColorToRed(); Console.Beep(); Console.WriteLine("\n\n That is not an option."); MainScreen.TryAgain(); } else if (errorType == "negative") { Console.Clear(); MainScreen.ChangeColorToRed(); Console.Beep(); Console.WriteLine("\n\n Do not write negative numbers"); MainScreen.TryAgain(); } else if (errorType == "movies>10") { Console.Clear(); Console.WriteLine(" A maximum of 10 movies can be played."); MainScreen.TryAgain(); } else if (errorType == "invalid movie rating") { Admin.AdminHeading(); MainScreen.ChangeColorToDarkCyan(); Console.WriteLine(" The rating inserted is not valid, please choose one of these options:"); Console.WriteLine("\tG - Any age"); Console.WriteLine("\tPG - 10 years or older"); Console.WriteLine("\tPG-13 - 13 years or older"); Console.WriteLine("\tR - 15 years or older"); Console.WriteLine("\tNC-17 - 17 years or older\n"); Console.WriteLine(" Press Enter to input Rating again."); Console.ReadLine(); } else if (errorType == "must be mortal") { Console.WriteLine(" You are too OLD! We don't want you to die, while watching movie."); MainScreen.TryAgain(); } else if (errorType == "risky customer") { Console.WriteLine("\n\n There are high chances, Customer could DIE while watching movie."); Thread.Sleep(500); MainScreen.TryAgain(); Admin.AdminHeading(); } else if (errorType == "too young") { Console.WriteLine( " You are '{0}' years old...\n" + " The movie '{1}' you chose has the rating of '{2}'.\n" + " Unfortunately, you cannot watch this movie\n", Guests.guestAge, Admin.moviesList[Guests.movieChoice - 1].Key, Admin.moviesList[Guests.movieChoice - 1].Value ); Thread.Sleep(2000); MainScreen.TryAgain(); } }
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(); }