Professional Documents
Culture Documents
Solution 6 Pages
Solution 6 Pages
class Book:
self.title = title
self.author = author
self.isbn = isbn
self.quantity = quantity
self.available_quantity = quantity
class Library:
def __init__(self):
self.books = []
self.books.append(book)
def display_books(self):
if title.lower() in book.title.lower():
return book
return None
book = self.search_book(title)
if book and book.available_quantity > 0:
book.available_quantity -= 1
else:
book = self.search_book(title)
if book:
book.available_quantity += 1
else:
pickle.dump(self.books, file)
try:
self.books = pickle.load(file)
except FileNotFoundError:
def main():
library = Library()
library.load_library_data('library_data.pkl')
while True:
if choice == "1":
library.add_book(new_book)
library.display_books()
found_book = library.search_book(search_title)
if found_book:
library.borrow_book(borrow_title)
library.return_book(return_title)
library.save_library_data('library_data.pkl')
break
else:
if __name__ == "__main__":
main()
Screenshots