public void deleteBook(int id) { Book book = null; boolean condition = false; for (Book b : books) { if (b.getId() == id) { condition = true; book = b; break; } } if (condition) { books.removeIf((Book b) -> b.getId() == id); } if (book == null) { logger.warn("Book with id:" + Integer.toString(id) + " doesn't exists."); } }
public ArrayList<Book> getUnclaimedBooks() { ArrayList<Book> unclaimedBooks = new ArrayList<Book>(); for (Book book : books) { if (book.isUnclaimed()) { unclaimedBooks.add(book); } } return unclaimedBooks; }
public void addBook(Book book, ReplySystem replySystem) { if (!replySystem.equals(null)) { if (book.isInStore() == false) { if (books.contains(book) == false) { books.add(book); } } else { books.add(book); } for (Reply reply : replySystem.getReplies()) { boolean condition = (reply.getBook().getAuthor().equals(book.getAuthor())) && ((reply.getBook().getName().equals(book.getName()))) && ((reply.getBook().getPrice() == book.getPrice())) && ((reply.getBook().getDateOfPublication().get(Calendar.YEAR)) == (book.getDateOfPublication().get(Calendar.YEAR))) && ((reply.getBook().getDateOfPublication().get(Calendar.MONTH)) == (book.getDateOfPublication().get(Calendar.MONTH))) && ((reply.getBook().getDateOfPublication().get(Calendar.DATE)) == (book.getDateOfPublication().get(Calendar.DATE))) && (book.isInStore()); if (condition) { reply.setExecuted(true); ; } } } }