A console-based Library Book Management System built with Java to demonstrate core Object-Oriented Programming (OOP) concepts through a practical library simulation.
The application allows users to add books, borrow and return books, and view books based on their current availability. It also demonstrates abstraction, encapsulation, inheritance, polymorphism, collections, and exception handling.
-
β Add new books to the library
-
π Support multiple book types:
- Academic Books
- Storybooks
-
π₯ Borrow available books
-
π€ Return borrowed books
-
π Display all books
-
β Display only available books
-
π Display currently borrowed books
-
π Automatically generate unique book IDs
-
β οΈ Handle invalid user input -
π« Handle unavailable or invalid book operations using custom exceptions
-
π₯οΈ Simple interactive command-line interface
This project was designed primarily as an implementation of fundamental Java OOP principles.
Book is implemented as an abstract class containing common properties and behaviors shared by all books.
public abstract class Book {
...
public abstract String getBookType();
}Book properties such as ID, title, author, and borrowing status are kept private and accessed through public methods.
private int bookId;
private String title;
private String author;
private boolean isBorrowed;Specialized book classes inherit from the base Book class.
Book
/ \
/ \
AcademicBook Storybook
Different book types override methods such as getBookType() and displayDetails().
The library stores different subclasses through a common reference type:
ArrayList<Book> books;This allows the system to treat different book types uniformly while preserving their specialized behavior.
The application uses both Java's built-in exceptions and a custom exception:
BookNotAvailableExceptionThis is used when a user attempts an invalid book operation, such as borrowing an already borrowed book.
Library-Book-Management-System/
β
βββ Library Book Management System/
β βββ Book.java
β βββ AcademicBook.java
β βββ Storybook.java
β βββ Library.java
β βββ LibraryManagementSystem.java
β βββ BookNotAvailableException.java
β
βββ .gitignore
βββ LICENSE
βββ README.md
| Class | Responsibility |
|---|---|
Book |
Abstract base class for all books |
AcademicBook |
Represents academic/reference books |
Storybook |
Represents fiction/story books |
Library |
Manages the book collection and library operations |
LibraryManagementSystem |
Provides the main menu and user interaction |
BookNotAvailableException |
Handles invalid book availability operations |
When the application starts, it creates a Library object and loads a small set of sample books for demonstration.
The user is then presented with an interactive menu:
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β LIBRARY MANAGEMENT SYSTEM β
β βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ£
β [1] Add a New Book β
β [2] Borrow a Book β
β [3] Return a Book β
β [4] Display All Books β
β [5] Display Available Books β
β [6] Display Borrowed Books β
β [7] Exit β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
Books are stored in an ArrayList<Book> and can transition between:
Available βββββββΊ Borrowed
β² β
βββββββββββββββββββ
Return
- Java
- Object-Oriented Programming
- Abstract Classes
- Inheritance
- Encapsulation
- Polymorphism
- Method Overriding
- Collections Framework
ArrayList- Exception Handling
- Custom Exceptions
- Input Validation
- Console-Based Application Development
Make sure Java is installed on your system.
Check your Java installation:
java -version
javac -versiongit clone https://github.com/tracolerd/Library-Book-Management-System.gitNavigate to the project directory:
cd Library-Book-Management-SystemThen enter the source directory:
cd "Library Book Management System"javac *.javajava LibraryManagementSystemA typical session may look like:
1. Start the application
2. View the available books
3. Borrow a book using its Book ID
4. View borrowed books
5. Return the borrowed book
6. Add a new academic book or storybook
7. Exit the application
This project is intentionally designed as a simple educational console application focused on demonstrating Java and OOP concepts.
It currently uses in-memory data storage through ArrayList, so library data is not persisted after the application terminates.
It does not currently include:
- Database integration
- User authentication
- Admin/librarian accounts
- GUI or web interface
- Book reservations
- Due-date management
- Fine calculation
- Multi-user support
The system could be extended with:
- πΎ MySQL/PostgreSQL database integration
- π User authentication and role-based access
- π Book search and filtering
- π Due dates and return deadlines
- π° Automatic fine calculation
- π₯οΈ JavaFX/Swing graphical interface
- π REST API and web frontend
- π Library statistics and reporting
- π₯ Separate librarian and member accounts
This project provides hands-on practice with:
- Designing classes and relationships
- Applying the four fundamental OOP principles
- Using inheritance and method overriding
- Managing objects with Java collections
- Designing and handling custom exceptions
- Building an interactive command-line application
- Structuring a small Java application into multiple classes
Tracolerd
GitHub: https://github.com/tracolerd
This project is licensed under the MIT License. See the LICENSE file for details.