@Override void execute(Library library, Console console) { if (library.numberOfBooksCheckedOut() == 0) { console.printMessage("There are no books available for return"); return; } console.printMessage("Books available for return:"); console.printLibraryItemList(library.checkedOutBooks()); console.printMessage("> Enter book number: "); Integer selection = getAsInteger(console.getUserCommand()); if (selection != null && library.bookIsCheckedOut(selection)) { library.returnBook(selection); console.printMessage("Thank you for returning the book"); } else { console.printMessage("That is not a valid book to return"); } }
private void setUserInput(String inputs[]) { List<String> inputList = Arrays.asList(inputs); when(console.getUserCommand()).thenAnswer(AdditionalAnswers.returnsElementsOf(inputList)); }