Design: Library Management System
Design the core classes and their relationships for managing books, members, librarians, and loans. Exclude UI and database implementation details.
Functional Requirements
Non-Functional Requirements
Jump into concepts and practice - no test required
Library Management System Classes
+----------------+ +----------------+ +----------------+
| Book | | Member | | Librarian |
+----------------+ +----------------+ +----------------+
| - bookId | | - memberId | | - librarianId |
| - title | | - name | | - name |
| - author | | - email | | - email |
| - ISBN | | - loans: List | | |
| - isAvailable | +----------------+ +----------------+
+----------------+ | |
^ | |
| | |
| | |
| | |
| | |
| | |
| v v
| +----------------+
| | Loan |
| +----------------+
| | - loanId |
| | - book: Book |
| | - member: Member|
| | - loanDate |
| | - dueDate |
| | - returnDate |
| +----------------+Book logically holds details about books such as title, author, and ISBN.Member is for library users, Librarian manages operations, and Loan tracks borrowing, so they don't store book details.borrowBook inside the Member class in Python?self as the first parameter to access object data.book parameter after self.class Loan:
def __init__(self, book, member):
self.book = book
self.member = member
loan = Loan('1984', 'Alice')
print(loan.book, loan.member)__init__ assigns book and member to instance variables.loan.book and loan.member outputs the strings '1984' and 'Alice' separated by space.Librarian class:class Librarian:
def __init__(self, name):
self.name = name
def addBook(book):
print(f"Adding {book} to library")self as the first parameter to access instance data.addBook lacks self, so it will cause an error when called on an instance.Book stores book info, Member represents users, Loan tracks borrow records, and Librarian manages library operations.Loan class should handle checking if a book is currently loaned out before allowing borrowing, as it tracks loan records.