コード例 #1
0
 public void availableMovies(User user) {
   String header = String.format("%-20s %-6s %-20s %-5s", "MOVIE", "YEAR", "DIRECTOR", "RATING");
   System.out.println("\n" + header);
   System.out.println("==========================================================");
   if (user.isAdminUser() || user.isNormalUser()) {
     System.out.print(movieSection.listAvailableItems());
   }
   dispatcher.start(Constants.MENU_RUN, user);
 }
コード例 #2
0
 public void availableBooks(User user) {
   if (user.isAdminUser() || user.isNormalUser()) {
     String header = String.format("%-20s %-20s %-6s", "BOOK", "AUTHOR", "YEAR");
     System.out.println("\n" + header);
     System.out.println("==================================================");
     String result = bookSection.listAvailableItems();
     System.out.print(result);
   }
   dispatcher.start(Constants.MENU_RUN, user);
 }
コード例 #3
0
 public void checkedOutBooks(User user) {
   if (user.isAdminUser()) {
     String header = String.format("%-20s %-20s %-6s", "BOOK", "AUTHOR", "YEAR");
     System.out.println("\n" + header);
     System.out.println("==================================================");
     System.out.print(bookSection.listCheckedOutItems());
   }
   dispatcher.start(Constants.MENU_RUN, user);
 }
コード例 #4
0
 public Operations parse(User user) {
   if (user == null) {
     return new IncorrectLogin(view);
   }
   if (user.isLibrarian()) {
     return new UserController(view, user, this, Messages.librarianMenu);
   } else {
     return new UserController(view, user, this, Messages.userMenu);
   }
 }
コード例 #5
0
 public void displayUserHavingBooks(User user) {
   if (user.isAdminUser()) {
     String header =
         String.format(
             "%-20s %-20s %-20s %-12s %-20s %-20s %-6s",
             "LIBRARY NUMBER", "NAME", "EMAIL", "MOBILE", "BOOK", "AUTHOR", "YEAR");
     System.out.println("\n" + header);
     System.out.println(
         "============================================================================================================================");
     System.out.println(bookSection.returnUsersHavingBooks());
   }
   dispatcher.start(Constants.MENU_RUN, user);
 }
コード例 #6
0
 public Operations parse(String userInput, User user) {
   switch (userInput) {
     case "0":
       return new Quit();
     case "1":
       return new Display(
           view, booksLibrary.getItems(), Messages.listOfBooks, Messages.booksHeader);
     case "2":
       return new CheckOut(
           view,
           booksLibrary,
           Messages.enterBookName,
           Messages.successfulBookCheckout,
           Messages.unsuccessfulBookCheckOut,
           user);
     case "3":
       return new CheckIn(
           view,
           booksLibrary,
           Messages.enterBookName,
           Messages.successfulBookCheckIn,
           Messages.unsuccessfulBookCheckIn,
           user);
     case "4":
       return new Display(
           view, moviesLibrary.getItems(), Messages.listOfMovies, Messages.moviesHeader);
     case "5":
       return new CheckOut(
           view,
           moviesLibrary,
           Messages.enterMovieName,
           Messages.successfulMovieCheckout,
           Messages.unsuccessfulMovieCheckOut,
           user);
     case "6":
       return new CheckIn(
           view,
           moviesLibrary,
           Messages.enterMovieName,
           Messages.successfulMovieCheckIn,
           Messages.unsuccessfulMovieCheckIn,
           user);
     case "7":
       return new DisplayUserInformation(view, user);
     case "8":
       if (user.isLibrarian())
         return new DisplayCheckedOutList(
             view,
             booksLibrary.getCheckedOutItems(),
             Messages.listOfCheckedOutBooks,
             Messages.checkedOutBooksHeader);
       return new NullObject();
     case "9":
       if (user.isLibrarian())
         return new DisplayCheckedOutList(
             view,
             moviesLibrary.getCheckedOutItems(),
             Messages.listOfCheckedOutMovies,
             Messages.checkedOutMoviesHeader);
     case "10":
       if (user.isLibrarian())
         return new DisplayListOfUsers(
             view, login.getUsers(), Messages.listOfUsers, Messages.userHeader);
     case "11":
       if (user.isLibrarian()) return new NullObject();
     default:
       return new InvalidOption(view);
   }
 }