Skip to content

AlexGithubs/java-blackjack

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

1 Commit
Β 
Β 

Repository files navigation

Blackjack Java Project

🎲 Overview

This project is a complete command-line Blackjack game implemented in Java. It follows the official rules of Blackjack and was designed for the APCS course as a capstone project. The game logic includes card management, betting, dealer behavior, and player decision-making. Built and tested on the CodeHS platform.

πŸ“ Classes Implemented

Core Components

  • Card.java: Represents a single playing card with suit and rank. Includes support for evaluating Ace as 1 or 11.
  • Deck.java: Contains a standard 52-card deck. Supports shuffling and dealing.
  • Shoe.java: Represents one or more decks combined. Automatically reshuffles when running low on cards.
  • Hand.java: A hand of cards for either a player or dealer. Calculates total value with Ace flexibility.
  • Player.java: Holds a player's bankroll and current hand. Implements decision-making like hitting or doubling down.
  • Dealer.java: Contains the main game logic: dealing cards, determining outcomes, and handling house rules.
  • Game.java: Main driver class. Instantiates Dealer and begins the game loop.

Testers

Each class (except Game.java) includes a corresponding Tester file to validate correctness:

  • CardTester.java
  • DeckTester.java
  • ShoeTester.java
  • HandTester.java
  • PlayerTester.java
  • DealerTester.java

🧠 Key Features

  • Accurate Blackjack rules:
    • Dealer hits on 16, stands on 17
    • Blackjack pays 3:2
    • Push when hands tie
    • Ace handling (1 or 11)
  • Full game loop:
    • Betting system with bankroll
    • Double down (only on initial hand)
    • Game ends when bankroll is depleted
  • Enhancements:
    • Discard pile tracking and reshuffling
    • Multiple hand support
    • Bullet-proofing user inputs

πŸ§ͺ Testing

All major classes were tested using dedicated tester files. These ensure that methods behave as expected and validate interactions like:

  • Drawing cards from a shoe
  • Calculating hand values correctly
  • Dealer and player decisions
  • Handling busts, Blackjacks, and pushes

πŸ“œ Documentation

All classes include Javadoc-style comments and inline documentation for clarity and maintainability.

πŸ” Known Limitations

  • The code is designed specifically for the CodeHS environment and may require adjustment to run locally.
  • The project uses terminal output only; no GUI was implemented.

βœ… Project Completed

This project meets all benchmark requirements:

  • UML diagrams (7 classes)
  • Javadocs and commenting
  • Code organization and Java conventions
  • Complete and playable game

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published