A console-based Library Management System built with Java, demonstrating all four core Object-Oriented Programming (OOP) principles: Encapsulation, Inheritance, Polymorphism, and Abstraction.
| Name | Student ID |
|---|---|
| Nasr Mohamed Ahmed Monib | 202409010305 |
| Gofran Osama Fathi Abdalla | 202405010044 |
| Nasir Mohamed Abdelgafar Elyas | 202405010110 |
| Ahmed Mustafa Mohamed Mustata | 202505010027 |
| Saiful Bin Noor | 201907030005 |
Program: BCSSE
Subject: BIT1123 — Object Oriented Programming (Java)
Lecturer: Sir Nazmirul Izzad Bin Nasir
- Overview
- Problem Statement
- Project Structure
- OOP Concepts
- Classes Description
- Error Handling
- How to Run
- Sample Output
This system is designed to manage the daily operations of a library. It allows librarians and members to handle tasks such as:
- Borrowing and returning books
- Managing member information (Student & Faculty)
- Monitoring available library resources
The system replaces traditional manual record-keeping with a structured, digital solution that is faster, more consistent, and less error-prone.
Managing a library manually presents several challenges:
- Inefficient record keeping — Paper systems make it hard to track book availability and borrowing history.
- Inconsistent borrowing rules — Students and faculty have different borrowing durations, which are difficult to enforce manually.
- Time-consuming processes — Searching for books and checking availability takes significant time.
- Lack of standardization — Different staff may handle requests differently, leading to inconsistent outcomes.
- Providing a simple console menu for all library operations
- Differentiating between Student and Faculty members with clear borrowing rules (7 days vs. 30 days)
- Displaying available books and processing borrowing requests automatically
LibraryManagementSystem/
│
├── Main.java # Entry point — handles user interaction and program flow
├── LibraryItem.java # Abstract base class for all library items
├── Book.java # Concrete subclass representing a book
├── Member.java # Base class for library members
├── StudentMember.java # Student member (7-day borrowing)
├── FacultyMember.java # Faculty member (30-day borrowing)
└── Library.java # Manages the collection of library items
All class fields are declared private and accessed only through public getter methods. This protects internal data from unintended modification.
// LibraryItem.java
private String title;
private String author;
public String getTitle() { return title; }
public String getAuthor() { return author; }Applied in: LibraryItem, Member, Library
Child classes extend parent classes using the extends keyword and reuse shared attributes and methods, avoiding code duplication.
// StudentMember.java
public class StudentMember extends Member {
public StudentMember(String name, int memberId) {
super(name, memberId);
}
}Hierarchies:
Book→ extendsLibraryItemStudentMember→ extendsMemberFacultyMember→ extendsMember
The same method name behaves differently depending on the object type at runtime (method overriding).
// FacultyMember.java
@Override
public void borrowBook(Book book) {
System.out.println("Faculty " + getName() + " borrowed " + book.getTitle() + " for 30 days.");
}StudentMember.borrowBook()→ "borrowed for 7 days"FacultyMember.borrowBook()→ "borrowed for 30 days"
LibraryItem is an abstract class with an abstract method displayInfo(), forcing all subclasses to provide their own implementation.
// LibraryItem.java
abstract class LibraryItem {
public abstract void displayInfo();
}Applied in: LibraryItem (implemented by Book)
| Concept | Applied In | Mechanism |
|---|---|---|
| Encapsulation | LibraryItem, Member, Library |
Private fields + public getters |
| Inheritance | Book, StudentMember, FacultyMember |
extends keyword + super() |
| Polymorphism | borrowBook(), displayInfo() |
@Override in subclasses |
| Abstraction | LibraryItem |
Abstract class + abstract method |
| Class | Type | Description |
|---|---|---|
LibraryItem |
Abstract | Base class for all library items. Defines common fields (title, author) and the abstract displayInfo() method. |
Book |
Concrete | Extends LibraryItem. Implements displayInfo() to print book details. |
Member |
Concrete | Base class for library members. Holds name and memberId with a base borrowBook() method. |
StudentMember |
Concrete | Extends Member. Overrides borrowBook() — 7-day loan period. |
FacultyMember |
Concrete | Extends Member. Overrides borrowBook() — 30-day loan period. |
Library |
Concrete | Manages an ArrayList of LibraryItem objects. Provides addItem(), displayItems(), and getItem(). |
The system handles invalid user input gracefully at every interactive step using try-catch blocks and input validation loops.
| Case | Scenario | Behavior |
|---|---|---|
| Case 1 | User enters a letter instead of membership type (1/2) | Prompts user to try again |
| Case 2 | User enters an invalid ID (non-numeric, ≤ 0, or ≥ 999) | Prompts user to re-enter a valid 3-digit ID |
| Case 3 | User selects an out-of-range book number or enters a letter | Prompts user to pick a valid book number |
| Case 4 | User enters invalid input during book confirmation | Loops back to book selection and re-confirmation |
- Java JDK 8 or higher
- A terminal or IDE (e.g., IntelliJ IDEA, Eclipse, VS Code)
-
Clone the repository:
git clone <repository-url> cd LibraryManagementSystem
-
Compile all Java files:
javac *.java -
Run the program:
java Main
-----Library System-------
Are you a Student or a Faculty Member?:
1- A student [Enter: 1]:
2- A Faculty Member [Enter: 2]:
Enter your membership type (1 / 2): 1
You are a student
Enter your Username: User-1
Enter your ID [three numbers max]: 101
+++++++++++++++++++++++++++++++++++++++++++++++
Welcome Student User-1 [101]
You are allowed to borrow books for a maximum of 7 days
+++++++++++++++++++++++++++++++++++++++++++++++
Available Books:
1. Book: The Dark Tower by Stephen King
2. Book: Atomic Habits by James Clear
Enter the number of the book you want: 1
Do you want to confirm this choice (1- Yes / 2- No): 1
Congratulations! You have Borrowed a Book Successfully!
------------------------------------------------------------
This project successfully demonstrates the application of all four OOP pillars in a practical Java application. The system is modular, maintainable, and scalable — new member types or item types (e.g., Magazine, Journal) can easily be added by extending existing base classes without modifying the core logic.