Skip to content

Latest commit

 

History

2 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Java/OOP — Inventory Management System

A clean, modular, and menu-driven Inventory Management System developed in Java to demonstrate fundamental Object-Oriented Programming (OOP) principles, dynamic collections, defensive input parsing, and complete CRUD (Create, Read, Update, Delete) operations.

Note: This is an educational portfolio project designed to illustrate software design patterns and OOP concepts in Java. It is a console-based application built for learning and demonstration.


Table of Contents


Overview

The Java/OOP Inventory Management System is a console-based application that simulates real-world retail and warehouse product tracking. It enables users to register new products, inspect live inventory tables with automated stock-level calculations, search items by ID or name, modify product attributes, remove discontinued stock, and generate low-stock alert reports with total inventory valuations.


Features

  • Add New Products: Captures Product ID, Name, Category, Unit Price, and Quantity with duplicate ID prevention and non-negative constraints.
  • Tabular Inventory Ledger: Formats all registered products in an aligned table showing Unit Price, Quantity, Total Valuation, and Stock Health.
  • Real-Time Stock Status: Dynamically flags items as In Stock (>5 units), Low Stock (1–5 units), or Out of Stock (0 units).
  • Dual Search Capabilities:
    • Search by Product ID: Exact lookup returning detailed product card view.
    • Search by Name/Keyword: Case-insensitive substring matching across the inventory.
  • Selective Product Updates: Modifies Name, Category, Price, or Stock Quantity while retaining untouched fields.
  • Safe Product Deletion: Removes items after interactive confirmation (Y/N).
  • Low Stock & Reorder Alerts: Generates dedicated reports listing all items requiring immediate procurement.
  • Inventory Valuation Metrics: Automatically aggregates total unique product lines, total physical units in stock, and grand total monetary value.
  • Defensive Input Handling: Uses custom input reader routines to prevent program crashes from NumberFormatException or scanner buffer mismatches.

OOP Concepts Used

This project was architected to demonstrate core Object-Oriented Programming principles in Java:

1. Classes and Objects

  • Product Class: Models the entity with attributes (id, name, category, price, quantity) and behaviors (getTotalValue(), getStockStatus()).
  • Inventory Class: Manages the collection of Product objects, encapsulating all search, aggregation, and mutation routines.
  • Main Class: Orchestrates user interactions, menus, and program lifecycle.

2. Encapsulation & Data Hiding

  • All fields in Product and Inventory are declared private to prevent direct external manipulation.
  • Controlled access is provided through public getter and setter methods with validation checks (e.g., rejecting negative prices or empty strings).

3. Constructors

  • Default Constructors: Initialize objects with safe zero-value defaults.
  • Parameterized Constructors: Allow instantiating fully populated objects cleanly in one call:
    public Product(int id, String name, String category, double price, int quantity)

4. Aggregation / Composition

  • The Inventory class maintains a dynamic ArrayList<Product>, demonstrating a "has-a" relationship where the inventory holds multiple independent Product instances.

5. Polymorphism (Method Overriding)

  • Overrides the standard Object.toString() method in Product to return meaningful debugging metadata.

6. Separation of Concerns

  • Entity data model (Product.java), collection management logic (Inventory.java), and presentation/UI layer (Main.java) are separated into clean, modular classes.

Java Concepts Used

Java Concept Implementation in Code
Java Collections Framework Uses java.util.ArrayList and java.util.List to dynamically grow, filter, and iterate over product records.
Scanner & String Tokenization Uses java.util.Scanner, nextLine(), trim(), and equalsIgnoreCase() for flexible CLI input.
Formatted Console Output Employs System.out.printf with format specifiers (%-8d, %-22s, Rs. %.2f) for aligned tabular grids.
Exception Handling Employs try-catch blocks catching NumberFormatException to ensure invalid numeric inputs never crash the runtime.
Static & Final Members Uses static final modifiers for shared resources like Scanner and Inventory instances in Main.
String Algorithms Uses String.toLowerCase() and String.contains() for case-insensitive partial searches.

Technologies Used

  • Language: Java (JDK 17 / JDK 21 LTS compatible)
  • Standard Library: java.util.ArrayList, java.util.List, java.util.Scanner, java.util.InputMismatchException
  • Development Environment: Visual Studio Code / Terminal
  • Version Control: Git & GitHub

Project Structure

Java-OOP-Inventory-Management-System/
│
├── src/
│   ├── Product.java         # Entity class with encapsulated fields and methods
│   ├── Inventory.java       # Collection management & inventory business logic
│   └── Main.java            # Console UI, menu loop, and input validation
│
├── README.md                # Comprehensive documentation
├── .gitignore               # Excludes .class binaries, build folders, and IDE files
├── LICENSE                  # MIT License
│
└── screenshots/             # Output preview captures
    ├── main-menu.png
    ├── add-product.png
    ├── inventory-records.png
    ├── search-product.png
    └── update-delete-product.png

CRUD Operations

Operation Method in Inventory.java Description
Create addProduct(Product product) Validates ID uniqueness and appends new product to the collection.
Read displayAllProducts(), searchById(), searchByName() Renders formatted tables and searches records by ID or name substring.
Update updateProduct(id, name, category, price, qty) Modifies product fields while preserving existing values for blank inputs.
Delete deleteProduct(int id) Locates and removes product from the ArrayList upon user confirmation.

Data Storage

  • In-Memory Storage: Product records are stored in memory using java.util.ArrayList<Product>.
  • Pre-populated with realistic starter catalog items upon launch for immediate demonstration.
  • Designed as an in-memory educational system demonstrating dynamic collection management and OOP manipulation.

How to Run

Prerequisites

  • Java Development Kit (JDK 17 or higher) installed (java -version and javac -version).
  • VS Code (with the Extension Pack for Java) or any command-line terminal.

Step 1: Clone the Repository

git clone https://github.com/isrargabol/Java-OOP-Inventory-Management-System.git
cd Java-OOP-Inventory-Management-System

Step 2: Compile the Java Source Files

javac src/*.java

Step 3: Run the Application

java -cp src Main

(Alternatively, to compile into a separate bin directory:)

javac -d bin src/*.java
java -cp bin Main

Usage & Menu Options

Upon launching the application, the interactive main menu is presented:

=============================================
     JAVA INVENTORY MANAGEMENT SYSTEM
=============================================
1. Add New Product
2. View All Products
3. Search Product
4. Update Product Details
5. Delete Product
6. Low Stock Alerts
7. Inventory Summary Metrics
8. Exit
=============================================
Enter your choice: 
Option Action
1 Prompts for ID, Name, Category, Price, Quantity and adds a new product.
2 Displays all inventory products in a tabular layout with summary totals.
3 Searches for products by unique ID or by name keyword.
4 Updates product details selectively with input validation.
5 Deletes a product with Y/N confirmation.
6 Displays dedicated reorder report for low/out-of-stock items.
7 Shows grand totals for product count, stock count, and monetary valuation.
8 Exits the application cleanly.

Sample Output

1. Adding a Product

========== ADD NEW PRODUCT ==========
Enter Product ID: 106
Enter Product Name: Web Camera 1080p
Enter Category: Video & Streaming
Enter Unit Price (Rs.): 6500.00
Enter Stock Quantity: 12

Product added successfully!
---------------------------------------------
Product ID   : 106
Name         : Web Camera 1080p
Category     : Video & Streaming
Unit Price   : Rs. 6500.00
Stock Qty    : 12 units
Total Value  : Rs. 78000.00
Stock Status : In Stock
---------------------------------------------

2. Viewing Inventory Table

================================ ALL INVENTORY PRODUCTS ================================
ID       Product Name           Category           Unit Price     Quantity   Total Value      Status      
--------------------------------------------------------------------------------------------------------
101      Mechanical Keyboard    Peripherals        Rs. 4500.00    15         Rs. 67500.00     In Stock    
102      Gaming Mouse           Peripherals        Rs. 2200.00    24         Rs. 52800.00     In Stock    
103      24-inch IPS Monitor    Displays           Rs. 28500.00   4          Rs. 114000.00    Low Stock   
104      USB-C Hub 7-in-1       Accessories        Rs. 3800.00    0          Rs. 0.00         Out of Stock
105      External SSD 1TB       Storage            Rs. 16500.00   8          Rs. 132000.00    In Stock    
--------------------------------------------------------------------------------------------------------
Total Unique Products : 5
Total Physical Stock  : 51 units
Total Inventory Value : Rs. 366300.00

Screenshots

1. Main Menu

Main Menu

2. Add Product

Add Product

3. Inventory Records Table

Inventory Records

4. Search Product

Search Product

5. Update & Delete Operations

Update and Delete Product


Limitations

  • Console Interface (CLI): Does not feature a graphical UI (GUI) or web interface.
  • In-Memory Storage: Data resets upon application termination (no external database server).
  • Single-User Scope: Designed for single-session desktop execution.
  • No Role Authentication: Accessible without multi-tier employee vs. manager permissions.

Future Improvements

  • Graphical User Interface (GUI): Implement a modern desktop interface using JavaFX or Swing.
  • Database Integration: Connect to MySQL or PostgreSQL using JDBC / Hibernate.
  • File / Database Persistence: Add JSON/CSV export and import capabilities.
  • Authentication System: Add multi-role login (Admin, Manager, Cashier).
  • Barcode & Supplier Tracking: Support barcode scanning and supplier purchase order workflows.
  • REST API Backend: Migrate architecture to a Spring Boot microservice.

Learning Outcomes

  • Applying Object-Oriented Programming (OOP) principles in Java.
  • Designing encapsulated domain models with defensive mutators.
  • Utilizing the Java Collections Framework (ArrayList) for dynamic data management.
  • Writing resilient console input routines with comprehensive error handling.
  • Structuring a clean, professional Java repository ready for GitHub portfolios.

License

This project is licensed under the MIT License — feel free to use and adapt this code for educational and learning purposes.

About

A Java/OOP-based Inventory Management System demonstrating object-oriented programming, product management, and inventory operations.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages