@SuppressWarnings("unchecked") private static void configuring() throws ChoiceException { // get Movie from cineplex while (true) { System.out.println("------------------------"); System.out.println("Configuring " + currentCineplex.getCineplexName()); System.out.println( "1) Add or Remove or see Holiday from " + currentCineplex.getCineplexName()); System.out.println("2) Update the movie from " + currentCineplex.getCineplexName()); System.out.println("3) Add movie to the " + currentCineplex.getCineplexName()); System.out.println("4) Remove movie from " + currentCineplex.getCineplexName()); System.out.println("5) See List of Movie on " + currentCineplex.getCineplexName()); System.out.println("6) Configure another cineplex"); System.out.println("7) Quit"); System.out.println("-------- ----------------"); System.out.println("Please choose the option above"); int OptionMovie = scan.nextInt(); switch (OptionMovie) { case 1: ConfigureHoliday(); break; case 2: if (currentCineplex.getMovieList().size() > 0) { updatingMovie(); } else { System.out.println("Sorry there has no movie in " + currentCineplex.getCineplexName()); } break; case 3: if (currentCineplex.getMovieList().size() > 0) { addMovie(); } else { System.out.println("Sorry there has no movie in " + currentCineplex.getCineplexName()); } break; case 4: if (currentCineplex.getMovieList().size() > 0) { removeMovie(); } else { System.out.println("Sorry there has no movie in " + currentCineplex.getCineplexName()); } break; case 5: getMovieList(); break; case 6: viewCinemaFromDatabase(); return; case 7: System.out.println("Please choose the option below"); System.out.println("1) Quit to the cineplex configuration"); System.out.println("2) Quit from system"); int option = scan.nextInt(); if (option == 1) { viewCinemaFromDatabase(); } else if (option == 2) { System.out.println("Quitting from system"); } return; default: throw new ChoiceException("Sorry your input is not listed in our system"); } cDatabase.writeToDatabase("CineplexDatabase.dat", cineplexList); ratedMovieDatabase.writeToDatabase("RatedMovie.dat", listRatedMovie); holidayDatabase.writeToDatabase("HolidayDatabase.dat", listHoliday); } }
public static void main(String[] args) { boolean carryOn = true; try { while (carryOn) { int option = requestInput(MAIN_MENU); System.out.flush(); switch (option) { case 1: listMovies(0); break; case 2: listMovies(1); break; case 3: ArrayList<String> searchResult = new ArrayList<String>(); String searchMovie = ""; System.out.println("Enter movie title: "); sc.nextLine(); searchMovie = sc.nextLine(); System.out.flush(); for (int i = 0; i < cineplexList.size(); i++) { searchResult = searchCineplex(searchMovie, cineplexList.get(i)); if (searchResult.size() == 0) { System.out.println( cineplexList.get(i).getCineplexName() + ": No movie to show. \n"); } else { for (int j = 0; j < searchResult.size(); j++) { System.out.println(searchResult.get(j)); } } System.out.println(""); } break; case 4: int cineplexChoice = 0; requestInput(BOOKING_MAIN_INTERFACE); if (customer.confirmCustomerInfo()) cineplexChoice = requestInput(CINEPLEX_INTERFACE); else { System.out.println("Cancelled"); break; } movieListForSpecificCineplex = cineplexList.get(cineplexChoice - 1).getMovieListAvailable(); int movieChoice = requestInput(MOVIE_INTERFACE_FOR_SELECTED_CINEPLEX); movieChosen = movieListForSpecificCineplex.get(movieChoice - 1); movieScheduleList = movieChosen.getAvailableMovieDateList(); if (movieScheduleList.size() > 0) { int timingChoice = requestInput(SELECT_TIMING_INTERFACE); choiceDate = timingChoice; int ageGroup = requestInput(SELECT_AGE_GROUP_INTERFACE); double ticketPrice = movieChosen.getPrice(ageGroup, choosenDate); requestInput(SELECT_SEAT); movieChosen.notificationMessage(); System.out.println( "Ticket price is SGD " + ticketPrice + "." + " Proceed to payment? (y / n)"); String confirmation = sc.next(); if (confirmation.equals("y") || confirmation.equals("Y")) try { displayTicket(timingChoice); } catch (Exception e) { e.printStackTrace(); } userDatabase.writeToDatabase("CineplexDatabase.dat", cineplexList); customerDatabase.writeToDatabase("CustomerDatabase.dat", customerList); } else { System.out.println("No schedule movie"); } break; case 5: System.out.println("Select a movie to rate: "); requestInput(MOVIE_INTERFACE); break; case 6: requestInput(CHECK_MOVIE_INTERFACE); break; case 7: System.out.println("Quitting"); System.exit(0); } } } catch (Exception e) { e.printStackTrace(); System.out.println("Your input is invalid that make this program undergo exception fault"); System.out.println("1) Restart Program"); System.out.println("2) Quit"); sc.nextLine(); int option = sc.nextInt(); if (option == 1) { UserApplication.main(args); } else { System.out.println("Quit"); return; } } }