This repository contains the solution for Task 3: Library Management System.
The goal was to develop a mini Library Management System using Object-Oriented Programming (OOP) principles in Java, demonstrating class interaction and encapsulation. The system is designed to manage book records and handle the core transactions of issuing and returning books.
The system is built upon three main classes:
Book.java
: Represents a physical book with properties liketitle
,author
,isbn
, and an internal status (isIssued
).User.java
: Represents a library member with properties likeuserId
andname
. It also maintains a local list ofissuedBooks
.Library.java
: Acts as the central Controller. It holdsArrayList
collections of allBook
andUser
objects and contains the main business logic forissueBook()
andreturnBook()
.
- Book Management: Allows adding new books and users.
- Encapsulation: Book and User details are managed through getters/setters, and the internal lists are managed by the
Library
class. - Issue Logic:
- Finds the book by ISBN and the user by ID.
- Fails if the book is already issued, the user/book is not found.
- Updates the book's status and adds the book to the user's
issuedBooks
list.
- Return Logic:
- Reverses the issue process.
- Removes the book from the user's
issuedBooks
list. - Sets the book's status back to
isIssued = false
.
- Ensure all four files (
Book.java
,User.java
,Library.java
, andMain.java
) are in the same folder. - Compile the Java files:
javac *.java
- Run the main class:
java Main