Skip to content

williamromero11/Project-3

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Project Three: Nile Dot Com E-Store Simulation (Event-Driven GUI)

Overview

Nile Dot Com E-Store Simulation is a Java-based standalone GUI application implementing a comprehensive e-commerce simulation through event-driven programming principles. Built with Swing and adhering to model-view-controller separation, the system models online retail operations including inventory management, shopping cart functionality, and transaction logging.

The program demonstrates advanced Java concepts including event handling, file I/O operations, GUI component management, and object-oriented design while solving a practical e-commerce problem. It features a complete graphical interface for managing store inventory, processing customer orders, and maintaining permanent transaction records.

Key technical achievements include thread-safe CSV file operations, dynamic GUI state management, proper separation of business logic from presentation layer, and comprehensive error handling for all user interaction scenarios.

Features

  • Event-Driven GUI with Swing components and dynamic state updates
  • Inventory Management through CSV file integration with real-time validation
  • Shopping Cart System with capacity limits and real-time calculations
  • Transaction Logging with unique timestamp-based transaction IDs
  • Tax & Discount Calculations applied according to business rules
  • Comprehensive Error Handling for stock shortages, invalid items, and cart limits
  • Invoice Generation with formatted output and file persistence

Features GUI Components

GUI Components

  • Input Area: Text fields for item ID and quantity entry

  • Cart Display Panel: Shows current items, quantities, prices, and running totals

  • Control Buttons (6 total):

  • Search For Item #X - Validate and retrieve item details

  • Add Item #X To Cart - Add validated item to shopping cart

  • Delete Last Item From Cart - Remove most recent cart addition

  • Check Out - Finalize order and generate invoice

  • Start New Order - Clear current transaction

  • Exit Program - Gracefully terminate application

Technical Architecture

  • NileStoreGUI.java - Main GUI controller and event handler
  • Item.java - Data model representing inventory items
  • TransactionLogger.java - CSV file writer for transaction logging
  • InventoryManager.java - File reader and inventory validator
  • ShoppingCart.java - Cart operations and total calculations

Key Methods Implemented

  • initializeGUI() - Set up all Swing components with proper layouts

  • handleSearchButton() - Validate item ID against inventory.csv

  • handleAddToCart() - Update cart model and refresh display

  • calculateTotals() - Compute subtotal, tax, discount, and final total

  • generateInvoice() - Create formatted invoice and update transaction log

  • resetGUI() - Clear inputs and prepare for next transaction

File Specifications

  • Input: inventory.csv

item_id,description,stock_status,quantity,price
A123,"Wireless Mouse","In Stock",50,29.99
B456,"Mechanical Keyboard","Out of Stock",0,89.99
C789,"USB-C Cable","In Stock",100,19.99
  • Output: transactions.csv (Append-only)

text
transaction_id,date_time,item_id,quantity,unit_price,total_amount
20260201_235959_001,2026-02-01 23:59:59,A123,2,29.99,63.58
20260202_120015_002,2026-02-02 12:00:15,C789,5,19.99,105.94

Business Rules

  • Cart Limit: Maximum 5 distinct items per transaction

  • Tax Rate: 6% applied to subtotal

  • Discount Rules: Tiered discounts based on cart total

  • Stock Validation: Quantity requested must be ≤ available stock

  • Transaction IDs: Generated as YYYYMMDD_HHMMSS_XXX format

How to Use

  • Compile the program:
javac *.java
  • Prepare inventory file:

Create inventory.csv with item data

Place in same directory as compiled classes
  • Run the application:
java NileStoreGUI

Typical workflow:

  • Enter item ID and quantity

  • Click "Search" to validate availability

  • Click "Add to Cart" to include item

  • Repeat for up to 5 items

  • Click "Check Out" to generate invoice

  • View transaction in transactions.csv

Example Session

Input Operations:
1. Enter: Item ID = "A123", Quantity = "2"
2. Click: "Search For Item #1"
3. Click: "Add Item #1 To Cart"
4. Enter: Item ID = "C789", Quantity = "5"
5. Click: "Search For Item #2"
6. Click: "Add Item #2 To Cart"
7. Click: "Check Out"

input

Output:
- GUI displays cart with 2 items
- Invoice popup shows:
  Subtotal: $149.93
  Tax (6%): $9.00
  Discount: $7.50
  Total: $151.43
- transactions.csv appended with new record

input

Memory Management

  • All GUI components properly disposed on window close

  • File streams correctly opened and closed

  • No memory leaks in event listener registrations

  • Efficient object reuse for repeated operations

Error Handling Scenarios

  1. Invalid Item ID: "Item not found in inventory" message

  2. Out of Stock: "Item currently unavailable" notification

  3. Quantity Exceeds Stock: "Insufficient quantity available" alert

  4. Cart Full: "Maximum 5 items per cart" warning

  5. Empty Cart Checkout: "Add items before checking out" prompt

Author

William Romero
University of Central Florida

About

(Event-Driven GUI)

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages