Java OOP Assessment (Intermediate) π Scenario: Library Management System
You are building a simple system to manage a library. The system must handle books and different types of members.
π― Objectives
Your solution must demonstrate:
β Encapsulation (private fields + getters/setters) β Inheritance (base class + subclasses) β Use of loops β Conditional logic β Accessing, updating, and deleting data from attributes (e.g., arrays or lists) π§± Requirements
- Base Class: LibraryItem
Create a class with:
Attributes (Encapsulation required) title (String) id (String) isAvailable (boolean) Methods Getters and setters for all fields checkoutItem() β marks item as unavailable returnItem() β marks item as available 2. Subclass: Book (Inheritance)
Extend LibraryItem
Additional Attributes author (String) genre (String) Methods Constructor to initialize all fields Override toString() to display book details 3. Base Class: Member Attributes (Encapsulation) name (String) memberId (String) borrowedBooks (Array or ArrayList of Book objects) Methods borrowBook(Book book) Only allow borrowing if the book is available Use conditionals returnBook(String bookId) Use a loop to find the book Remove it from the list viewBorrowedBooks() Use a loop to display all borrowed books 4. Subclass: PremiumMember
Extend Member
Additional Attribute maxBooksAllowed (int) Requirements Override borrowBook(): Use a conditional to check if the member reached their limit Prevent borrowing if limit exceeded 5. Library Class Attributes books (ArrayList) Methods addBook(Book book) removeBook(String id) Use loop to find and delete a book searchBook(String title) Return matching books (use loop + condition) displayAvailableBooks() Show only available books π§ Functional Requirements
Your program must demonstrate:
β Loops Searching books Listing borrowed books Removing books β Conditionals Checking availability Borrow limits Prevent invalid operations β Data Manipulation Add books Remove books Borrow/return books π₯οΈ Main Program
Create a Main class to:
Create several books Add them to the library Create: 1 normal member 1 premium member Simulate: Borrowing books Returning books Removing a book from the library Displaying available books π§© Example Output (Guideline) Book borrowed successfully. Book is not available. You have reached your borrowing limit. Returning book... Book removed from library. Available books:
- The Hobbit by Tolkien
library-system/ β βββ src/main/java/ β βββ library/ β βββ LibraryItem.java β βββ Book.java β βββ Member.java β βββ PremiumMember.java β βββ Library.java β βββ Main.java β βββ src/test/java/ β βββ library/ β βββ LibraryTest.java β βββ MemberTest.java β βββ BookTest.java β βββ pom.xml