Inventory Tracking System
Course Code: IN2343-G3
Student Name: Arshdeep Singh
Student ID: 202302145
1. Problem Description
Businesses must have a robust system in place to manage inventory, track stock levels, and
guarantee flawless operations. Aiming at real-time tracking of inventory levels, this project
builds an Inventory Tracking System using Object-Oriented Java concepts.
• Object additions and deletions by administrator.
• Simplified systems of replenishment and item sales.
2. UML Diagram
2.1. UML
2.2. Design Description
Architectural concepts of Object- Oriented Programming are embodied in this Inventory
Tracking System:
Important qualities (name, price, quantity) in item are private, under controlled access.
Item objects let Customer and Administrator classes manage inventory control and purchase.
UpdateStock() and purchaseItem() allows one to reach dynamic behavior.
Every class covers specific duties in modular architecture:
a. Item: Indicates particular items in stock.
Managers stock addition and removal under supervision.
a. Client: Oversees item acquisitions.
3. Code Implementation
3.1. Java Code
import [Link];
import [Link];
// Item Class
class Item {
private String name;
private double price;
private int quantity;
public Item(String name, double price, int quantity) {
[Link] = name;
[Link] = price;
[Link] = quantity;
public String getDetails() {
return "Item: " + name + ", Price: $" + price + ", Stock: " + quantity;
public void updateStock(int change) {
[Link] += change;
public boolean isAvailable(int requestedQuantity) {
return [Link] >= requestedQuantity;
public void reduceStock(int quantity) {
if ([Link] >= quantity) {
[Link] -= quantity;
} else {
[Link]("Insufficient stock for " + name);
// Administrator Class
class Administrator {
public void viewInventory(List<Item> items) {
[Link]("Current Inventory:");
for (Item item : items) {
[Link]([Link]());
public void addItem(Item item, List<Item> items) {
[Link](item);
[Link]([Link]() + " added to inventory.");
public void removeItem(Item item, List<Item> items) {
if ([Link](item)) {
[Link]([Link]() + " removed from inventory.");
} else {
[Link]("Item not found in inventory.");
// Customer Class
class Customer {
private String name;
public Customer(String name) {
[Link] = name;
public void purchaseItem(Item item, int quantity) {
if ([Link](quantity)) {
[Link](quantity);
[Link](name + " purchased " + quantity + " units of " + [Link]());
} else {
[Link]("Purchase failed: Insufficient stock for " + [Link]());
// Main Class
public class InventoryTrackingSystem {
public static void main(String[] args) {
// Initialize inventory and administrator
List<Item> inventory = new ArrayList<>();
Administrator admin = new Administrator();
// Add items to inventory
Item item1 = new Item("Laptop", 1200.50, 10);
Item item2 = new Item("Smartphone", 800.75, 5);
[Link](item1, inventory);
[Link](item2, inventory);
// View inventory
[Link](inventory);
// Customer purchase
Customer customer = new Customer("John");
[Link](item1, 2); // John purchases 2 laptops
[Link](item2, 6); // Attempt to purchase more than stock
// View inventory after purchase
[Link](inventory);
3.2. Code Explanation
1. Item Class:
o Represents individual inventory items.
o Methods like updateStock(), isAvailable(), and reduceStock() manage stock
levels.
2. Administrator Class:
o Handles the addition, removal, and viewing of items in the inventory.
3. Customer Class:
o Facilitates item purchases and ensures sufficient stock availability.
4. Main Class:
o Demonstrates the system's functionality by simulating administrator and customer
actions.
4. Testing Use Cases
Use Case 1: Adding and Viewing Items
1. Input: Administrator adds "Laptop" and "Smartphone" to the inventory.
2. Output: Inventory displays the details of the two added items.
Use Case 2: Purchasing an Item
1. Input: Customer "John" attempts to purchase 2 laptops.
2. Output: Inventory stock for laptops decreases by 2, and the purchase is confirmed. If
requested stock exceeds availability, an error message is displayed.
5. Reflection on Challenges
Establishing Effective Inventory Control
One of the main challenges became ensuring the system could handle edge conditions, such
insufficient supplies during procurement efforts. Early installations lacked validation, hence
erroneous stock updates upon consumer requests for limited supplies.
To manage this, validation logic was included to the functions available() and reduce Stock().
These checks help to avoid overbuying and assure consistent stock levels even in edge
circumstances.
Staying away from functional redundancy
Another challenge was avoiding duplication of capability across the Administrator and Customer
classes, especially given both classes interact with the same inventory. At first, repeated codes
for stock-related operations carried the risk of complicating the maintenance and expansion of
the system.
The item class combined basic operations including stock reductions, availability checks, and
stock updates. This modular architecture minimized duplicity and streamlined code
administration.
Creating a friendly interface
Especially for activities like inventory control and purchasing control, making sure the system
was user-friendly for customers generated challenges. Early iterations of the interface were
confusing, which would have misled consumers all through interactions.
These days, the focus switched to providing useful console outputs and employing informative
method names. For example, whilst terminal messages were enhanced to give users immediate
feedback on their operations, tools like viewInventory() and purchaseItem() were aimed to make
their operation explicit.