Loading...
The Library Management System needs to cater to two primary roles: librarians and members. The system must handle the following functions:
From the requirements, the main objects in the system are:
Member and Librarian.Member and Librarian as subclasses.EBook or AudioBook.User and Book.User or Book.Library class exists.Book
class Book:
def __init__(self, title, author, isbn, genre, copies):
self.title = title
self.author = author
self.isbn = isbn
self.genre = genre
self.copies = copies # Available copies
User (Base Class)
class User:
def __init__(self, user_id, name):
self.user_id = user_id
self.name = name
class Member(User):
def init(self, user_id, name):
super().init(user_id, name)
self.borrowed_books = []
class Librarian(User):
def init(self, user_id, name):
super().init(user_id, name)
Transaction
class Transaction:
def init(self, transaction_id, member, book, borrow_date, return_date=None):
self.transaction_id = transaction_id
self.member = member
self.book = book
self.borrow_date = borrow_date
self.return_date = return_date
self.fine = 0
Library
class Library:
def init(self):
self.books = []
self.users = []
self.transactions = []
def add_book(self, book):
self.books.append(book)
def register_user(self, user):
self.users.append(user)
Member and Librarian) can replace the base class User without breaking functionality.Library) depend on abstractions (like User).title or author to optimize searches.