public boolean checkoutBookItem(BookItem bookItem) { if (this.getTotalBooksCheckedOut() >= Constants.MAX_BOOKS_ISSUED_TO_A_USER) { ShowError("The user has already checked-out maximum number of books"); return(false); } BookReservation bookReservation = BookReservation.fetchReservationDetails(bookItem.getBarcode()); if (bookReservation != null && bookReservation.getMemberId() != this.getId()) { // book item has a pending reservation from another user ShowError("This book is reserved by another member"); return(false); } else if (bookReservation != null) { // book item has a pending reservation from the give member, update it bookReservation.updateStatus(ReservationStatus.COMPLETED); } if (!bookItem.checkout(this.getId())) { return(false); } this.incrementTotalBooksCheckedout(); return(true); }