Skip to content

huderdcv/oop-library-system

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

📚 Library Management System (OOP Showcase)

Java Architecture License

A clean, modular Java console application designed to practice Object-Oriented Programming best practices, specifically Encapsulation and the Single Responsibility Principle.

📖 Overview

This project simulates the core operations of a physical library. Unlike basic "Hello World" scripts, this application separates the Data Layer (Book), Logic Layer (Library), and Presentation Layer (LibraryApp) to simulate a real-world software architecture.

It demonstrates how to manage in-memory state, handle user input validation, and manipulate relationships between objects.

🏗️ Architecture & Design

The project follows a "Separation of Concerns" philosophy:

  • Book.java (Model): A POJO (Plain Old Java Object) using Encapsulation (private fields, public getters/setters) to protect data integrity.
  • Library.java (Service): Manages the business logic. It handles the ArrayList collection and uses static variables to track global inventory state.
  • LibraryApp.java (View/Controller): Handles the UI (Console) and User Input (Scanner), keeping the core logic clean of print statements.

Class Diagram

classDiagram
    class Book {
        -String id
        -String title
        -int stock
        +getId()
        +setStock()
    }
    class Library {
        -ArrayList~Book~ books
        -static int totalBooks
        +addBook(Book)
        +lendBook(String id)
        +searchBook(String id)
    }
    class LibraryApp {
        -Library library
        -Scanner scanner
        +start()
        -showMenu()
        -handleOptions()
    }

    LibraryApp --> Library : uses
    Library o-- Book : manages
Loading

🚀 Key Features

  • Inventory Management: Dynamic addition of books using ArrayList.
  • Stock Tracking: Real-time updates to global book counts using static properties.
  • Lending System: Logic to decrease stock upon lending and validate availability.
  • Search: ID-based lookup algorithms.

🛠️ Technical Concepts Applied

  • Encapsulation: All class attributes are private; access is controlled via methods.
  • Polymorphism: Overriding the toString() method for clean object visualization.
  • State Management: Using static to maintain counters across the application lifecycle.
  • Input Handling: Robust use of java.util.Scanner for interactive menus.

💻 How to Run

  1. Clone the repository:
git clone https://github.com/huderdcv/java-oop-library-system.git
  1. Compile the source:
javac library/*.java
  1. Run the Main class:
java library.Main

About

A modular console application demonstrating core OOP principles (Encapsulation, SRP) and Separation of Concerns in Java. Features dynamic inventory management and user input handling.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages