Beispiel #1
0
    def rent_book(self, book: Book) -> bool:
        """ Rents this book

        :param book: The book to be rented
        :return: True iff the book was successfully rented. False otherwise
        """

        if not book.is_rented and book not in self.rented_books and \
                book.owned_by in self.libraries:

            book.due_date = date.today() + timedelta(days=7)
            book.is_rented = True
            book.rent_list.enqueue(self)
            # Add the member to the front of the queue to signify that they
            # are renting the book

            self.rented_books.append(book)

            return True

        elif book.is_rented:
            print(
                "The book is currently being rented and you will be placed on"
                "the wait list.")

            book.rent_list.enqueue(self)
            return True

        return False