Library Management System - Problem
Design a comprehensive Library Management System using object-oriented programming principles. The system should support core library operations including book borrowing, returning, searching, and overdue tracking.
Requirements:
- Create
Bookclass with properties: id, title, author, isbn, isAvailable - Create
Memberclass with properties: memberId, name, borrowedBooks, maxBooks (default 5) - Create
Libraryclass that manages books and members - Implement operations: addBook, addMember, borrowBook, returnBook, searchBooks, getOverdueBooks
The system should handle edge cases like borrowing unavailable books, exceeding member limits, and tracking overdue items (books borrowed for more than 14 days).
Input & Output
Example 1 — Basic Library Operations
$
Input:
operations = [["addBook", 1, "1984", "George Orwell", "978-0-452-28423-4"], ["addMember", 101, "Alice Smith", 3], ["borrowBook", 101, 1]]
›
Output:
["Book 1984 added", "Member Alice Smith added", "Book 1984 borrowed by Alice Smith"]
💡 Note:
First add a book with ID 1, then add member Alice with limit 3 books, then Alice successfully borrows the book.
Example 2 — Search and Limits
$
Input:
operations = [["addBook", 2, "Animal Farm", "George Orwell", "978-0-452-28424-1"], ["addMember", 102, "Bob Jones", 1], ["borrowBook", 102, 2], ["borrowBook", 102, 2], ["searchBooks", "Orwell"]]
›
Output:
["Book Animal Farm added", "Member Bob Jones added", "Book Animal Farm borrowed by Bob Jones", "Member has reached borrowing limit", ["Animal Farm by George Orwell - Borrowed"]]
💡 Note:
Add book and member with 1-book limit. Bob borrows successfully, then fails due to limit. Search finds Orwell's book showing Borrowed status.
Example 3 — Return Book
$
Input:
operations = [["addBook", 3, "Brave New World", "Aldous Huxley", "978-0-06-085052-4"], ["addMember", 103, "Carol White"], ["borrowBook", 103, 3], ["returnBook", 103, 3], ["searchBooks", "Brave"]]
›
Output:
["Book Brave New World added", "Member Carol White added", "Book Brave New World borrowed by Carol White", "Book Brave New World returned", ["Brave New World by Aldous Huxley - Available"]]
💡 Note:
Complete borrow-return cycle. Carol borrows and returns the book. Search confirms book is Available again.
Constraints
- 1 ≤ operations.length ≤ 1000
- Each operation has valid parameters
- Book IDs and Member IDs are unique positive integers
- Member names and book titles are non-empty strings
- maxBooks is between 1 and 10 if specified
Visualization
Tap to expand
💡
Explanation
AI Ready
💡 Suggestion
Tab
to accept
Esc
to dismiss
// Output will appear here after running code