This repository contains a Java-based implementation of a simplified e-commerce system that supports key features such as product expiration, shipping management, cart operations, and checkout processing — all designed using clean Object-Oriented Programming principles.
-
Product Management
- Define products with name, price, quantity
- Support for:
- Expirable products (e.g., Cheese)
- Shippable products with weight (e.g., TV, Cheese)
- Non-expirable/non-shippable items (e.g., Mobile Scratch Cards)
-
Cart System
- Add items to the cart with a specific quantity
- Prevent adding expired or out-of-stock items
-
Checkout Process
- Validate customer balance
- Calculate:
- Subtotal
- Shipping fee (based on total weight at 30 EGP/kg)
- Final paid amount
- Deduct balance and reduce product stock
- Print:
- Shipment notice
- Checkout receipt
-
Shipping Logic
- Interfaces ensure that only eligible products implement
Shippable - Automatically collects and processes shippable items for shipping service
- Interfaces ensure that only eligible products implement
Productis an abstract base class for all product types.ShippableandExpirableare marker interfaces for optional behavior.- Concrete products (
Cheese,TV,MobileScratchCard) implement relevant interfaces. CartandCartItemmanage purchase operations.Customerholds balance and handles payment.ShippingServiceandCheckoutServiceencapsulate business rules.ECommerceAppacts as the composition root for wiring and executing the use case.
- Language: Java 8+
- No external libraries
- Pure Object-Oriented Programming
Clone the repository to your local machine:
git clone https://github.com/AhmedAmgadElsharkawy/ecommerce-system-java.git java src/ECommerceSystem.java
This project is open-source and available under the MIT Licence.