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 ArrayList<String> searchCineplex(String title, Cineplex cineplex) {

    ArrayList<String> result = new ArrayList<String>();

    movieListForSpecificCineplex = cineplex.getMovieList();

    for (int i = 0; i < movieListForSpecificCineplex.size(); i++) {
      Movie curMovie = new Movie();
      curMovie = movieListForSpecificCineplex.get(i);
      if ((curMovie.getTitle().toLowerCase()).equals(title.toLowerCase())) {
        // processing the status first
        String status = "";
        for (int j = 0; j < curMovie.getArrayListOfMovieDate().size(); j++) {
          status = curMovie.getArrayListOfMovieDate().get(j).getStatus();
          if (status.equals("End of Showing")) {
            status = "Now Showing";
          }
        }

        result.add(
            cineplex.getCineplexName()
                + ":  "
                + "\n"
                + curMovie.getTitle()
                + "\nPrice: "
                + Double.toString(curMovie.getNormalPrice())
                + "\nDuration: "
                + curMovie.getDuration()
                + "\nStatus:  "
                + status);
      }
    }

    return result;
  }
 @SuppressWarnings("unchecked")
 private static void ConfigureHoliday() {
   System.out.println("\n------------------------");
   System.out.println("1) Add Holiday");
   System.out.println("2) Remove Holiday");
   System.out.println("3) See the holiday list");
   System.out.println("\n------------------------");
   System.out.println("Please choose the option above");
   int holidayOption = scan.nextInt();
   if (holidayOption == 1) {
     System.out.println("please specify ");
     System.out.print("Year(yyyy): ");
     int holidayYear = scan.nextInt();
     System.out.print("Month(MM): ");
     int holidayMonth = scan.nextInt();
     System.out.print("Day(dd): ");
     int holidayDay = scan.nextInt();
     DateMovie holidayDate = new DateMovie(holidayYear, holidayMonth, holidayDay);
     System.out.println("Holiday on " + holidayDate.getYearMonthDay() + " has been set");
     listHoliday.add(holidayDate);
   } else if (holidayOption == 2) {
     System.out.println("Holiday schedule of " + currentCineplex.getCineplexName());
     int removeHoliday = getIndexHoliday();
     listHoliday.remove(removeHoliday - 1);
     System.out.println("changes has been saved to the system\n");
   } else if (holidayOption == 3) {
     System.out.println("Holiday schedule of " + currentCineplex.getCineplexName());
     for (int i = 0; i < listHoliday.size(); i++) {
       DateMovie holiday = (DateMovie) listHoliday.get(i);
       System.out.printf("%d) %s\n", i + 1, holiday.getYearMonthDay());
     }
     System.out.println("\n");
   } else {
     System.out.println("Sorry your input is not listed in our system ");
     System.out.println("Please choose below option");
     System.out.println("1) Quit to " + currentCineplex.getCineplexName() + " configuration");
     System.out.println("2) Configure Holiday again");
     int option = scan.nextInt();
     if (option == 1) {
       System.out.println("");
       return;
     } else {
       ConfigureHoliday();
     }
     return;
   }
 }
  private static void updatingMovie() {
    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("\nPlease choose one movie to configure\n");
    int indexMovie = scan.nextInt();
    if (indexMovie > currentCineplex.getMovieList().size()) {
      System.out.println("Sorry your movie option is invalid");
      System.out.println("Please choose again");
      updatingMovie();
      return;
    }
    currentMovie = currentCineplex.getMovie(indexMovie - 1);

    if (currentCineplex.getMovieList().size() != 0) {
      // later need to add the Date attribute so it will detect current time and the time when you
      // put the object
      System.out.println("What description you want to configure");
      System.out.println("1) title");
      System.out.println("2) duration");
      System.out.println("3) ratingPG");
      System.out.println("4) Genre");
      System.out.println("5) price");
      System.out.println("6) Director");
      System.out.println("7) Cast");
      System.out.println("8) Synopsis");
      System.out.println("9) date and status");

      int MovieConfigurationDescription = scan.nextInt();
      System.out.flush();
      switch (MovieConfigurationDescription) {
        case 1:
          System.out.println("insert the new title");
          scan.nextLine();
          String newTitle = scan.nextLine();
          currentMovie.setTitle(newTitle);
          break;
        case 2:
          System.out.println("insert the new duration in minute");
          scan.nextLine();
          String newDuration = scan.nextLine();
          currentMovie.setDuration(newDuration);
          break;
        case 3:
          System.out.println("Set the new RatingPG");
          scan.nextLine();
          String newRatingPG = scan.nextLine();
          currentMovie.setRatingPG(newRatingPG);
          break;
        case 4:
          System.out.println("Set the new Genre of the movie");
          scan.nextLine();
          String newGenre = chooseMovieType();
          currentMovie.setGenre(newGenre);
          break;
        case 5:
          System.out.println("insert the new price of the movie in SGD");
          scan.nextLine();
          double price = scan.nextDouble();
          currentMovie.setPrice(price);
          break;
        case 6:
          System.out.println("insert the new Director of the movie");
          scan.nextLine();
          String director = scan.nextLine();
          currentMovie.setDirector(director);
          break;
        case 7:
          ArrayList<String> listCasting = currentMovie.getCastList();
          System.out.println("List of  cast: ");
          for (int i = 0; i < listCasting.size(); i++) {
            System.out.printf("%d) %s\n", i + 1, listCasting.get(i));
          }
          System.out.println("");
          System.out.println("Editting the cast");
          System.out.println("1) add new cast");
          System.out.println("2) Remove cast");
          System.out.println("3) Update new  List of cast");

          int optionCast = scan.nextInt();
          if (optionCast == 1) {
            System.out.println("insert the new cast ");
            scan.nextLine();
            String newCast = scan.nextLine();
            listCasting.add(newCast);
          } else if (optionCast == 2) {
            System.out.println("List of cast");
            // need to exception
            int deleteCast = getIndexCast(listCasting);
            listCasting.remove(deleteCast - 1);
          } else if (optionCast == 3) {
            System.out.println("How many cast you want to add");
            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);
            }
            listCasting = castList;
          } else {
            System.out.println("Sorry your option is not listed in our system");
          }
          currentMovie.setCastList(listCasting);
          break;
        case 8:
          System.out.println("insert the new Synopsis");
          scan.nextLine();
          String synopsis = scan.nextLine();
          currentMovie.setSynopsis(synopsis);
          break;
        case 9:
          configuringDate();
          break;
        default:
          System.out.println("Sorry your choice is not listed in our system");
          System.out.println("Please choose the below option");
          System.out.println("1) Quit to " + currentCineplex.getCineplexName() + " configuration");
          System.out.println("2) Editing Movie again");
          int option = scan.nextInt();
          if (option == 1) {
            return;
          } else if (option == 2) {
            System.out.println("");
            updatingMovie();
            return;
          }
      }
      System.out.println("\nchanges has been saved to our system\n");
    } else {
      System.out.println(
          "\nDont have any movie on the list, please add at least one of the movie to the cinema");
    }
  }
 @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);
   }
 }