|
@@ -0,0 +1,66 @@
|
|
|
|
|
+class LibraryBook:
|
|
|
|
|
+ def __init__(self, title, author, isbn, year_published):
|
|
|
|
|
+ self.title = title
|
|
|
|
|
+ self.author = author
|
|
|
|
|
+ self.isbn = isbn
|
|
|
|
|
+ self.year_published = year_published
|
|
|
|
|
+ self.available = True
|
|
|
|
|
+
|
|
|
|
|
+ def borrow(self):
|
|
|
|
|
+ if self.available:
|
|
|
|
|
+ self.available = False
|
|
|
|
|
+ print(f"You have borrowed '{self.title}' by {self.author}.")
|
|
|
|
|
+ else:
|
|
|
|
|
+ print(f"Sorry, '{self.title}' is currently not available.")
|
|
|
|
|
+
|
|
|
|
|
+ def return_book(self):
|
|
|
|
|
+ if not self.available:
|
|
|
|
|
+ self.available = True
|
|
|
|
|
+ print(f"You have returned '{self.title}'. Thank you!")
|
|
|
|
|
+ else:
|
|
|
|
|
+ print(f"'{self.title}' was not borrowed.")
|
|
|
|
|
+
|
|
|
|
|
+ def detail(self):
|
|
|
|
|
+ print(f"Title: {self.title}")
|
|
|
|
|
+ print(f"Author: {self.author}")
|
|
|
|
|
+ print(f"ISBN: {self.isbn}")
|
|
|
|
|
+ print(f"Year Published: {self.year_published}")
|
|
|
|
|
+ print(f"Available: {'Yes' if self.available else 'No'}")
|
|
|
|
|
+
|
|
|
|
|
+ book1 = LibraryBook("To Kill a Mockingbird", "Harper Lee", "978-0-06-112008-4", 1960) # type: ignore
|
|
|
|
|
+ book2 = LibraryBook("1984", "George Orwell", "978-0-452-28423-4", 1949) # type: ignore
|
|
|
|
|
+ book3 = LibraryBook("Pride and Prejudice", "Jane Austen", "978-0-19-953556-9", 1813) # type: ignore
|
|
|
|
|
+ #book1
|
|
|
|
|
+ detail = book1.detail()
|
|
|
|
|
+ borrow = book1.borrow()
|
|
|
|
|
+ detail = book1.detail()
|
|
|
|
|
+ return_book = book1.return_book()
|
|
|
|
|
+ detail = book1.detail()
|
|
|
|
|
+
|
|
|
|
|
+ #book2
|
|
|
|
|
+ detail = book2.detail()
|
|
|
|
|
+ borrow = book2.borrow()
|
|
|
|
|
+ detail = book2.detail()
|
|
|
|
|
+ return_book = book2.return_book()
|
|
|
|
|
+ detail = book2.detail()
|
|
|
|
|
+
|
|
|
|
|
+ #book3
|
|
|
|
|
+ detail = book3.detail()
|
|
|
|
|
+ borrow = book3.borrow()
|
|
|
|
|
+ detail = book3.detail()
|
|
|
|
|
+ return_book = book3.return_book()
|
|
|
|
|
+ detail = book3.detail()
|
|
|
|
|
+
|
|
|
|
|
+ #newattribute
|
|
|
|
|
+ def availability(self):
|
|
|
|
|
+ if self.available:
|
|
|
|
|
+ print("True")
|
|
|
|
|
+ elif self.borrow:
|
|
|
|
|
+ print("False")
|
|
|
|
|
+ if self.return_book:
|
|
|
|
|
+ print("True")
|
|
|
|
|
+ if self.already_borrowed:
|
|
|
|
|
+ print("This book is already borrowed.")
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|