Skip to content

Latest commit

Β 

History

History
322 lines (249 loc) Β· 10.5 KB

File metadata and controls

322 lines (249 loc) Β· 10.5 KB

Auction System

A comprehensive Java-based desktop application for managing online auctions. This project implements a full-featured auction system with separate user roles for buyers and sellers, featuring a modern Swing-based GUI.

πŸ“‹ Table of Contents

🎯 Overview

The Auction System is an Object-Oriented Programming (OOP) project that demonstrates core Java concepts including:

  • Inheritance and Polymorphism
  • Abstract Classes
  • Exception Handling
  • File I/O Operations
  • GUI Development with Java Swing
  • Data Persistence
  • User Authentication

The system allows users to register as either Buyers or Sellers, with role-specific functionalities and dashboards.

✨ Features

For Buyers:

  • Browse Auctions: View all available auction items with search and filter capabilities
  • Place Bids: Bid on active auctions with password verification
  • Watchlist Management: Save items to watchlist for easy access
  • Bid Tracking: View all bids placed and track active/ended auctions
  • Statistics Dashboard: View bidding statistics including total bids, active bids, won auctions, and total spent

For Sellers:

  • Item Management: Create, view, and delete auction items
  • Auction Monitoring: Track bids, current prices, and auction status
  • Statistics Dashboard: View total items, active/ended auctions, and revenue
  • Item Details: Add descriptions and set starting prices for items

General Features:

  • User Authentication: Secure login and registration system
  • Password Hashing: SHA-256 password encryption for security
  • Data Persistence: Automatic save/load functionality
  • Modern UI: Clean, intuitive interface with hover effects and modern design
  • Search & Filter: Advanced search and filtering options for auction items
  • Sorting: Multiple sorting options (by name, price, current bid)

πŸ“ Project Structure

OOP_Project/
β”œβ”€β”€ backend/
β”‚   └── src/
β”‚       └── auction/
β”‚           β”œβ”€β”€ AuctionSystem.java          # Main system class
β”‚           β”œβ”€β”€ users/
β”‚           β”‚   β”œβ”€β”€ User.java               # Abstract base class
β”‚           β”‚   β”œβ”€β”€ Buyer.java              # Buyer implementation
β”‚           β”‚   └── Seller.java             # Seller implementation
β”‚           β”œβ”€β”€ items/
β”‚           β”‚   └── AuctionItem.java        # Auction item model
β”‚           β”œβ”€β”€ file/
β”‚           β”‚   └── FileUtil.java           # File I/O operations
β”‚           β”œβ”€β”€ util/
β”‚           β”‚   └── PasswordUtil.java       # Password hashing utility
β”‚           └── exceptions/
β”‚               └── BidTooLowException.java # Custom exception
β”œβ”€β”€ frontend/
β”‚   └── src/
β”‚       └── auction/
β”‚           └── ui/
β”‚               β”œβ”€β”€ MainUI.java             # Main entry point
β”‚               β”œβ”€β”€ LoginUI.java            # Login interface
β”‚               β”œβ”€β”€ RegisterUI.java         # Registration interface
β”‚               β”œβ”€β”€ DashboardBuyerUI.java   # Buyer dashboard
β”‚               β”œβ”€β”€ DashboardSellerUI.java  # Seller dashboard
β”‚               └── ViewAuctionsUI.java     # Auction browsing interface
β”œβ”€β”€ auction_data.txt                        # Data persistence file (auto-generated)
└── README.md                               # This file

πŸ›  Technologies Used

  • Java: Core programming language
  • Java Swing: GUI framework
  • Java Security API: For password hashing (SHA-256)
  • Java I/O: For file operations and data persistence

πŸš€ Getting Started

Prerequisites

  • Java Development Kit (JDK) 8 or higher
  • Any Java IDE (IntelliJ IDEA, Eclipse, NetBeans) or command line compiler

Installation

  1. Clone the repository:

    git clone <repository-url>
    cd OOP_Project
  2. Compile the project:

    Using command line:

    # Compile backend
    javac -d backend/out backend/src/auction/**/*.java
    
    # Compile frontend (requires backend classes)
    javac -cp backend/out -d frontend/out frontend/src/auction/**/*.java

    Or use your IDE:

    • Import the project into your IDE
    • Set source folders: backend/src and frontend/src
    • Build the project
  3. Run the application:

    java -cp "backend/out;frontend/out" auction.ui.MainUI

    Or run from your IDE by executing MainUI.java in the frontend/src/auction/ui/ package.

πŸ“– Usage

First Time Setup

  1. Launch the application: Run MainUI.java
  2. Register a new account:
    • Click "Register New Account"
    • Choose username (minimum 3 characters)
    • Set password (minimum 4 characters)
    • Select account type (Buyer or Seller)
    • Click "Create Account"

For Buyers

  1. Login with your buyer credentials
  2. Browse Auctions:
    • Click "Browse All Auctions" from the dashboard
    • Use search to find specific items
    • Filter by status (Active/Ended/With Bids/No Bids)
    • Sort by name, price, or current bid
  3. Place a Bid:
    • Select an item from the auction list
    • Click "Place Bid"
    • Enter bid amount (must be higher than current bid)
    • Enter password to confirm
    • Click OK
  4. Manage Watchlist:
    • Browse auctions and click "Add to Watchlist"
    • View watchlist from the dashboard
  5. View Statistics:
    • Check the Statistics tab for bidding overview

For Sellers

  1. Login with your seller credentials
  2. Add Items:
    • Go to "Add New Item" tab
    • Enter item name, description (optional), and starting price
    • Click "Add Item"
  3. Manage Auctions:
    • View all your items in "My Auctions" tab
    • See current bids and status
    • Delete items if needed
  4. View Statistics:
    • Check revenue, active/ended auctions in Statistics tab

Data Persistence

  • All data is automatically saved to auction_data.txt when you exit the application
  • Data is automatically loaded when you start the application
  • The data file is created in the project root directory

πŸ— Architecture

Design Patterns

  1. MVC-like Structure: Separation of UI (frontend) and business logic (backend)
  2. Inheritance: User abstract class with Buyer and Seller implementations
  3. Exception Handling: Custom BidTooLowException for bid validation
  4. Singleton Pattern: AuctionSystem acts as a central data manager

Package Organization

  • auction: Core system classes
  • auction.users: User-related classes (User, Buyer, Seller)
  • auction.items: Auction item model
  • auction.file: File I/O utilities
  • auction.util: Utility classes (PasswordUtil)
  • auction.exceptions: Custom exceptions
  • auction.ui: User interface components

πŸ“¦ Classes and Components

Backend Classes

AuctionSystem

  • Central system class managing users and auctions
  • Static arrays for users and auction items
  • Methods: save(), load(), findUser()

User (Abstract)

  • Base class for all users
  • Handles username and password management
  • Password hashing using SHA-256

Buyer extends User

  • Manages watchlist and bid history
  • Methods: bidOnItem(), addToWatchlist(), getMyBids()

Seller extends User

  • Manages auction items
  • Methods: addItem(), removeItem(), getTotalRevenue()

AuctionItem

  • Represents an auction item
  • Tracks bids, highest bidder, and status
  • Methods: placeBid(), isActive(), getBidHistory()

FileUtil

  • Handles data persistence
  • Saves/loads users and auction items to/from text file
  • Uses Base64 encoding for descriptions

PasswordUtil

  • Provides SHA-256 password hashing
  • Ensures secure password storage

Frontend Classes

MainUI

  • Entry point of the application
  • Welcome screen with navigation options
  • Loads data on startup

LoginUI

  • User authentication interface
  • Validates credentials and redirects to appropriate dashboard

RegisterUI

  • New user registration
  • Validates input and creates Buyer/Seller accounts

DashboardBuyerUI

  • Buyer-specific dashboard
  • Tabs: Browse Auctions, My Bids, Watchlist, Statistics

DashboardSellerUI

  • Seller-specific dashboard
  • Tabs: My Auctions, Add New Item, Statistics

ViewAuctionsUI

  • Comprehensive auction browsing interface
  • Search, filter, and sort functionality
  • Bid placement and watchlist management

πŸ’Ύ Data Persistence

The system uses a text-based file (auction_data.txt) for data persistence:

  • Format: Pipe-delimited (|) text file
  • Sections: [USERS] and [ITEMS]
  • Encoding: Base64 for descriptions, plain text for other fields
  • Auto-save: Data is saved when exiting the application
  • Auto-load: Data is loaded when starting the application

πŸ”’ Security Features

  1. Password Hashing: All passwords are hashed using SHA-256 algorithm
  2. Password Verification: Required for sensitive operations (placing bids)
  3. Input Validation: Username and password length validation
  4. Bid Validation: Ensures bids are higher than current highest bid

🎨 UI Features

  • Modern Design: Clean, professional interface
  • Color-coded Roles: Different color schemes for buyers (blue) and sellers (green)
  • Hover Effects: Interactive buttons with visual feedback
  • Responsive Layout: Well-organized panels and tabs
  • User-friendly Messages: Clear error and success messages

πŸ“ Notes

  • Maximum users: 10
  • Maximum auction items per seller: 20
  • Minimum username length: 3 characters
  • Minimum password length: 4 characters
  • Data file location: Project root directory (auction_data.txt)

🀝 Contributing

This is an educational project. Feel free to:

  • Report bugs
  • Suggest improvements
  • Fork and enhance
  • Use as a learning resource

πŸ“„ License

This project is created for educational purposes as part of an Object-Oriented Programming course.

πŸ‘¨β€πŸ’» Author

Developed as part of OOP coursework demonstrating Java programming concepts and GUI development.


Note: This is a desktop application. Ensure you have Java installed and properly configured to run the application.