Exemplo n.º 1
0
 /** Adds the review. */
 private void addReview() {
   int id = 0;
   System.out.println(LINE_SPACING);
   String detail = null;
   int rating = 0;
   System.out.println("The movie list: ");
   movieUser.printMovieList();
   boolean done = false;
   while (!done) {
     System.out.print("Enter the id of the movie you want to review: ");
     try {
       id = Integer.parseInt(sc.nextLine());
     } catch (NumberFormatException e) {
       System.out.println("Please enter a valid number!");
       continue;
     }
     System.out.println(LINE_SPACING);
     System.out.print("Enter your review: ");
     detail = sc.nextLine();
     while (true) {
       System.out.print("Rate the movie(from 1 to 5): ");
       try {
         rating = Integer.parseInt(sc.nextLine());
       } catch (NumberFormatException e) {
         System.out.println("Please enter a valid number!");
         continue;
       }
       break;
     }
     System.out.println("Thank you for your review!");
     done = true;
   }
   movieUser.updateReview(id, detail, rating);
   movieUser.save();
 }