public static void removeMovie() { System.out.println("\n------------------------\n"); System.out.println("List movie of " + currentCineplex.getCineplexName() + "............"); for (int i = 0; i < currentCineplex.getMovieList().size(); i++) { System.out.println(i + 1 + ")"); System.out.printf("%s\n", currentCineplex.getMovieList().get(i).printDescription()); } System.out.println("\n------------------------\n"); System.out.println("which movie to be removed"); int optionRemoveMovie = scan.nextInt(); boolean pass = true; String movieDeleted = currentCineplex.getMovieList().get(optionRemoveMovie - 1).getTitle(); currentCineplex.removeMovie(currentCineplex.getMovieList().get(optionRemoveMovie - 1)); // need to remove the movie from rated movie if there has no such movie again in all the // cineplex for (int i = 0; i < cineplexList.size(); i++) { Cineplex cineplex = cineplexList.get(i); ArrayList<Movie> movieRemovedList = cineplex.getMovieList(); for (int j = 0; j < movieRemovedList.size(); j++) { if (movieRemovedList.get(j).getTitle().equals(movieDeleted)) { // means still has this movie in other cineplex so cannot delete it pass = false; break; } } } if (pass) { movieRated.removeMovie(movieDeleted); } System.out.println("changes has been saved to our system \n"); }
private static void addMovie() { // get the description of the movie from user String title, duration, genre, ratingPG; DateMovie dateMovie; double price; scan.nextLine(); System.out.println("insert the title of new movie"); title = scan.nextLine(); System.out.println("insert the duration of new movie, duration in minute"); duration = scan.nextLine(); System.out.println("insert the genre of the new movie"); genre = chooseMovieType(); scan.nextLine(); System.out.println("insert the RatingPG"); ratingPG = scan.nextLine(); System.out.println("insert the price of the movie in SGD"); price = scan.nextDouble(); System.out.println("insert the director"); scan.nextLine(); String director = scan.nextLine(); System.out.println("How many cast you want to add(at least 2)"); int castNumber = scan.nextInt(); while (castNumber < 2) { System.out.println("please choose at least 2"); System.out.println("How many cast you want to add(at least 2)"); castNumber = scan.nextInt(); } ArrayList<String> castList = new ArrayList<String>(); scan.nextLine(); for (int i = 0; i < castNumber; i++) { System.out.printf("name of cast %d: ", i + 1); String cast = scan.nextLine(); castList.add(cast); } System.out.println("\ninsert the synopsis"); String synopsis = scan.nextLine(); dateMovie = addDateOnNewMovie(title); Movie movie = new Movie(title, duration, ratingPG, genre, dateMovie, price, director, castList, synopsis); if (!dateMovie.getStatus().equals("Coming Soon")) { movieRated.addMovieList(movie); } currentCineplex.addMovie(movie); System.out.println("Changes has been saved to our system\n"); }
private static void editStatusTimeCinema() { System.out.println("Schedule " + currentMovie.getTitle() + " :"); currentMovie.getListDateStatusMovie(); System.out.println("\n"); ArrayList<DateMovie> listMovie = currentMovie.getArrayListOfDateMovie(); System.out.println("Please choose which date you want to configure"); int indexListMovie = scan.nextInt(); DateMovie currentDate = listMovie.get(indexListMovie - 1); System.out.println( "\nPlease choose which one you want to edit on " + currentDate.getStatusTimeMovie()); System.out.println("1) Time"); System.out.println("2) status"); System.out.println("3) cinema"); int timestatus = scan.nextInt(); if (timestatus == 1) { editTime(listMovie.get(indexListMovie - 1)); } else if (timestatus == 2) { System.out.println("insert the new Status"); scan.nextLine(); String newStatus = chooseStatusMovie(); currentDate.setStatus(newStatus); if (!newStatus.equals("Coming Soon")) { movieRated.addMovieList(currentMovie); } } else if (timestatus == 3) { System.out.println("List Cinema: "); int choosenCinema = getIndexCinema(); currentDate.setCinema(currentCineplex.getCinema(choosenCinema - 1)); } else { System.out.println("Sorry your choice is not listed in the system"); System.out.println("Please choose the below option"); System.out.println("1) Quit to Date configuration"); System.out.println("2) Editing Date attribute again"); int option = scan.nextInt(); if (option == 1) { return; } else if (option == 2) { System.out.println(""); editStatusTimeCinema(); return; } return; } }
private static int requestInput(int userInterface) { switch (userInterface) { case MAIN_MENU: System.out.println( "Choose one option:\n" + "1) List the movies available\n" + "2) List the movies with details\n" + "3) Search for movies\n" + "4) Book ticket\n" + "5) Rate,Review and see the top movie\n" + "6) View your booking\n" + "7) Exit\n"); // input check while (true) { if (sc.hasNextInt()) { int choice = sc.nextInt(); if (choice > 0 && choice <= 7) return choice; else continue; } sc.nextLine(); System.out.println("Invalid Option, choose again: "); } case CINEPLEX_INTERFACE: System.out.println("Choose cineplex:"); for (int i = 0; i < cineplexList.size(); i++) { System.out.printf("%d) ", i + 1); System.out.println(cineplexList.get(i).getCineplexName()); } // input check while (true) { if (sc.hasNextInt()) { int choice = sc.nextInt(); if (choice > 0 && choice <= cineplexList.size() + 1) return choice; else continue; } sc.nextLine(); System.out.println("Invalid Option, choose again: "); } case MOVIE_INTERFACE_FOR_SELECTED_CINEPLEX: System.out.println("Choose movie:"); for (int i = 0; i < movieListForSpecificCineplex.size(); i++) { System.out.printf("%d) ", i + 1); System.out.println(movieListForSpecificCineplex.get(i).getTitle()); } // input check while (true) { if (sc.hasNextInt()) { int choice = sc.nextInt(); if (choice > 0 && choice <= movieListForSpecificCineplex.size() + 1) return choice; else continue; } sc.nextLine(); System.out.println("Invalid Option, choose again: "); } case MOVIE_INTERFACE: /*System.out.println("Choose movie:"); for (int i = 0; i < movieListForAllCineplex.size(); i++){ System.out.printf("%d) ", i + 1); System.out.println(movieListForAllCineplex.get(i).getTitle()); } if (sc.hasNextInt()){ int choice = sc.nextInt(); while (choice >= movieListForAllCineplex.size() + 1){ System.out.println("Invalid Option, choose again: "); choice = sc.nextInt(); } return choice; } */ // print all the movie from ratedmovie System.out.println("1) Top 5 Movie based on Rating"); System.out.println("2) Top 5 movie based on Ticket Sales"); System.out.println("3) Rate the movie"); System.out.println("4) Write your review here"); System.out.println("5) See the review of your favorite movie"); int choiceOption = sc.nextInt(); switch (choiceOption) { case 1: ratedMovie.printTopFiveMovieBasedOnRating(); break; case 2: ratedMovie.printTopFiveMovieBasedOnTicket(); break; case 3: ratedMovie.printTopFiveMovieBasedOnRating(); System.out.println("which movie you want to rate"); int movieRatedOption = sc.nextInt(); while (true) { System.out.println("insert your rating here(1-5)"); double rating = sc.nextDouble(); if (rating > 5 || rating < 0) { System.out.println("sorry please put the acceptable range\n"); continue; } ratedMovie.updateMovieRating(movieRatedOption - 1, rating); break; } break; case 4: ratedMovie.printNormalMovieList(); System.out.println("Which movie you want to review"); int optionReview = sc.nextInt(); String movieHasRated = ratedMovie.getRatedMovie().get(optionReview - 1).getTitle(); sc.nextLine(); System.out.println("Insert your name please"); String bufferName = sc.nextLine(); System.out.println("Insert your review here"); String reviewIns = "Review: \n"; String reviewInserted = sc.nextLine(); reviewIns += reviewInserted; System.out.println(""); ratedMovie.updateMovieReview(bufferName, reviewIns, optionReview - 1); break; case 5: ratedMovie.printNormalMovieList(); System.out.println("which movie you want to see the review"); int optionReview1 = sc.nextInt(); ratedMovie.printReview(optionReview1 - 1); break; } ratedMovieDatabase.writeToDatabase("RatedMovie.dat", readMovie); System.out.println(""); return 0; case BOOKING_MAIN_INTERFACE: String customerEmailAdd; int customerPhoneNumber; System.out.println("Please enter your name: "); sc.nextLine(); String customerName = sc.nextLine(); System.out.println("Please enter your phone number: "); do { customerPhoneNumber = sc.nextInt(); if (customerPhoneNumber / 10000000 == 8 || customerPhoneNumber / 10000000 == 9) break; else System.out.println("Invalid phone number, enter again: "); ; } while (true); System.out.println("Please enter your e-mail address: "); do { customerEmailAdd = sc.next(); if (validateEmailAdd(customerEmailAdd) == false) System.out.println("Invalid email address, enter again: "); else break; } while (true); // need to check whether there has a people with the same name or not boolean pass = true; for (int i = 0; i < customerList.size(); i++) { customer = (Customer) customerList.get(i); if (customer.getEmailAdd().equals(customerEmailAdd)) { System.out.println("\nyour account has been in database"); pass = false; break; } } if (pass) { customer = new Customer(customerName, customerPhoneNumber, customerEmailAdd); customerList.add(customer); } return 0; case RATING_INTERFACE: System.out.println("Select movie from list below to rate: "); listMovies(0); System.out.print("Your selection: "); return 0; case SELECT_TIMING_INTERFACE: System.out.println("Choose timing:"); for (int i = 0; i < movieScheduleList.size(); i++) { System.out.printf("%d) ", i + 1); System.out.println(movieScheduleList.get(i).getTime()); } // input check while (true) { if (sc.hasNextInt()) { int choice = sc.nextInt(); if (choice > 0 && choice <= movieScheduleList.size() + 1) { choosenDate = movieScheduleList.get(choice - 1); return choice; } else continue; } sc.nextLine(); System.out.println("Invalid Option, choose again: "); } case SELECT_AGE_GROUP_INTERFACE: System.out.println("Select your age group:"); System.out.println( "1) Child (12 and below)" + "\n2) Adult (13-64)" + "\n3) Senior Citizen (65 and above)"); // input check while (true) { if (sc.hasNextInt()) { int choice = sc.nextInt(); if (choice > 0 && choice <= 4) return choice; else continue; } sc.nextLine(); System.out.println("Invalid Option, choose again: "); } case SELECT_SEAT: Cinema showingCinema = movieChosen.getAvailableMovieDateList().get(choiceDate - 1).getCinema(); boolean success = true; System.out.println(showingCinema.getSeatArrangement()); System.out.println("Select seat from cinema layout above: "); System.out.print("Row (A - J): "); String row = sc.next(); System.out.print("Column (1 - 10): "); int column = sc.nextInt(); while (!showingCinema.requestSeat(row, column)) { System.out.println("Seat taken, please select again"); System.out.print("(To cancel, enter 'z') Row (A - J): "); row = sc.next(); if (row.equals("z")) { success = false; break; } System.out.print("Column (1 - 10): "); column = sc.nextInt(); } if (success == true) { System.out.println("Successfully booked! movie name: " + movieChosen.getTitle()); customer.assignSeat(row + Integer.toString(column)); ratedMovie.updateMovieTicket(movieChosen.getTitle()); } else { System.out.println("Cancelled"); } return 0; case CHECK_MOVIE_INTERFACE: System.out.println("Enter your email address: "); do { customerEmailAdd = sc.next(); if (validateEmailAdd(customerEmailAdd) == false) System.out.println("Invalid email address, enter again: "); else break; } while (true); Customer currentCustomer = null; for (int i = 0; i < customerList.size(); i++) { if (((Customer) customerList.get(i)).getEmailAdd().equals(customerEmailAdd)) { currentCustomer = (Customer) customerList.get(i); break; } } if (currentCustomer != null) { ArrayList<String> temp = currentCustomer.getBookedMovieList(); String currentTransactionId = currentCustomer.getTransactionId(); printBookedMovie(temp, currentTransactionId); } else { System.out.println("Sorry database do not save your email, have you ordered yet?\n"); } return 0; default: return 0; } }