//Method if Ticket category is Student static bool StudentTicket(Order CurrentOrder, Screening screening, int ticketno) { while (true) { Console.Write("Please enter the level of study[Primary/Secondary/Teriary]: "); string levelofStudy = Console.ReadLine(); //Checks whether the user inputs "Primary", "Secondary", "Teriary". if (!new List <string>() { "Primary", "Secondary", "Teriary" }.Contains(levelofStudy)) { Console.WriteLine("Invalid level of study"); continue; } //Checks for age requirement if (screening.Movie.Classification == "R21") { Console.WriteLine("Ticket holder does not meet age requirement of 21 years old and above\n"); return(false); } else if ((screening.Movie.Classification == "NC16" || screening.Movie.Classification == "M18") && levelofStudy != "Teriary") { Console.WriteLine("Ticket holder does not meet age requirement of 16 years old and above\n"); return(false); } else if (screening.Movie.Classification == "PG13" && levelofStudy == "Primary") { Console.WriteLine("Ticket holder does not meet age requirement of 13 years old and above\n"); return(false); } CurrentOrder.AddTicket(new Student(screening, levelofStudy)); Console.WriteLine("Ticket #{0} has been ordered successfully", ticketno); return(true); } }
//Method if Ticket category is Senior static void SeniorTicket(Order CurrentOrder, Screening screening, int ticketno) { while (true) { Console.Write("Please enter year of birth [YYYY]: "); DateTime YOB; //Validation for DOB. try { YOB = DateTime.ParseExact(Console.ReadLine(), "yyyy", CultureInfo.InvariantCulture); } catch (Exception e) { Console.WriteLine("Invalid Year Of Birth"); continue; } if (YOB.Year > DateTime.Today.Year) { Console.WriteLine("Invalid Year Of Birth"); } if (DateTime.Today.Year - YOB.Year < 55) { Console.WriteLine("Only ages 55 and above are considered Elderly\nYou'll be considered as an Adult"); AdultTicket(CurrentOrder, screening, ticketno); break; } CurrentOrder.AddTicket(new SeniorCitizen(screening, YOB.Year)); Console.WriteLine("Ticket #{0} has been ordered successfully", ticketno); break; } }
//Method to add Movie Screenings into the existing screening list static void AddMovieScreening(List <Movie> movieList, List <Screening> screeningList, List <CinemaHall> cinemaHallList) { while (true) { int cinemahallindex, movieindex; Console.WriteLine("\nOption 2. Add Movie Screening\n"); DisplayAllCinemaHall(cinemaHallList); Console.Write("Select a cinema hall: "); try { cinemahallindex = Convert.ToInt32(Console.ReadLine()) - 1; } catch (Exception e) { Console.WriteLine("Cinema Hall Only"); continue; } if (0 > cinemahallindex || cinemahallindex >= cinemaHallList.Count) { Console.WriteLine("Invalid Cinema Hall"); continue; } Console.WriteLine(); DisplayAllMovies(movieList); Console.Write("Select a movie: "); try { movieindex = Convert.ToInt32(Console.ReadLine()) - 1; } catch (Exception e) { Console.WriteLine("MovieNo Only"); continue; }; if (0 > movieindex || movieindex >= movieList.Count) { Console.WriteLine("Invalid Movie"); continue; } Console.Write("\nSelect a screening type [2D/3D]: "); string Type = Console.ReadLine(); if (Type != "2D" && Type != "3D") { Console.WriteLine("Invalid Screening Type"); continue; } Console.Write("Enter a screening date and time [e.g. 01/01/2017 18:59](24 Hour format): "); DateTime Sdatetime; try { Sdatetime = DateTime.ParseExact(Console.ReadLine(), "dd/MM/yyyy HH:mm", CultureInfo.InvariantCulture); } catch (Exception e) { Console.WriteLine("Invalid Input"); continue; } Screening s = new Screening(Sdatetime, Type, cinemaHallList[cinemahallindex], movieList[movieindex]); screeningList.Add(s); Console.WriteLine("Movie screening successfully created."); break; } }
//Method if Ticket category is Adult static void AdultTicket(Order CurrentOrder, Screening screening, int ticketno) { while (true) { bool buyPopcorn = false; Console.Write("You're entitled to a $3 discount off the Popcorn Set.\n Do you want to purchase the Popcorn Set? [Y/N] "); string userinput = Console.ReadLine(); if (userinput == "Y") { buyPopcorn = true; } else if (userinput != "N") { Console.WriteLine("Invalid input"); continue; } CurrentOrder.AddTicket(new Adult(screening, buyPopcorn)); Console.WriteLine("Ticket #{0} has been ordered successfully", ticketno); break; } }
public Ticket(Screening screening) { Screening = screening; }
public Student(Screening screening, string levelofstudy) : base(screening) { LevelOfStudy = levelofstudy; }
public Adult(Screening screening, bool popcornoffer) : base(screening) { PopcornOffer = popcornoffer; }
public SeniorCitizen(Screening screening, int yearofbirth) : base(screening) { YearOfBirth = yearofbirth; }