Skip to content

Latest commit

Β 

History

7 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ“š Library Book Management System

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.


✨ Features

  • βž• 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


🧠 OOP Concepts Demonstrated

This project was designed primarily as an implementation of fundamental Java OOP principles.

1. Abstraction

Book is implemented as an abstract class containing common properties and behaviors shared by all books.

public abstract class Book {
    ...
    public abstract String getBookType();
}

2. Encapsulation

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;

3. Inheritance

Specialized book classes inherit from the base Book class.

           Book
          /    \
         /      \
AcademicBook   Storybook

4. Polymorphism

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.

5. Exception Handling

The application uses both Java's built-in exceptions and a custom exception:

BookNotAvailableException

This is used when a user attempts an invalid book operation, such as borrowing an already borrowed book.


πŸ—οΈ Project Structure

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 Responsibilities

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

πŸ”„ How It Works

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

πŸ› οΈ Technologies & Concepts

Technology

  • Java

Core Concepts

  • Object-Oriented Programming
  • Abstract Classes
  • Inheritance
  • Encapsulation
  • Polymorphism
  • Method Overriding
  • Collections Framework
  • ArrayList
  • Exception Handling
  • Custom Exceptions
  • Input Validation
  • Console-Based Application Development

▢️ Getting Started

Prerequisites

Make sure Java is installed on your system.

Check your Java installation:

java -version
javac -version

Clone the Repository

git clone https://github.com/tracolerd/Library-Book-Management-System.git

Navigate to the project directory:

cd Library-Book-Management-System

Then enter the source directory:

cd "Library Book Management System"

Compile

javac *.java

Run

java LibraryManagementSystem

πŸ§ͺ Example Workflow

A 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

πŸ“Œ Current Scope

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

πŸš€ Possible Future Improvements

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

🎯 Learning Objectives

This project provides hands-on practice with:

  1. Designing classes and relationships
  2. Applying the four fundamental OOP principles
  3. Using inheritance and method overriding
  4. Managing objects with Java collections
  5. Designing and handling custom exceptions
  6. Building an interactive command-line application
  7. Structuring a small Java application into multiple classes

πŸ‘¨β€πŸ’» Author

Tracolerd

GitHub: https://github.com/tracolerd


πŸ“„ License

This project is licensed under the MIT License. See the LICENSE file for details.

About

Built with Object Oriented Programming using JAVA

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages