Skip to content

happi1masia-pixel/LibraryTest

Β 
Β 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

5 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

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

  1. 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

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages

  • Java 100.0%