Also Check out the Python Version of this Project!
The Blackjack project is a console-based simulation of the Blackjack card game, also known as 21. Developed in Node.js, it showcases Object-Oriented Programming (OOP) principles and adheres to the SOLID design principles. The game features a dealer (computer) and a player (user), with the ability to hit or stand as per the classic game rules.
- Node.js installed on your system.
- npm (Node Package Manager)
- Clone the repository to your local machine.
- Navigate to the project directory.
- Install dependencies:
npm install
To start the game, run:
npx tsx index.ts
Follow the on-screen prompts to play Blackjack against the computer.
The project is organized into several key components:
Deck
: Manages a collection of playing cards.Hand
: Represents a hand of cards for a player or dealer.PlayingCard
: Defines a single playing card.BlackjackHand
&DealerHand
: Specialized hand classes for the player and dealer, respectively.Game
: A base class for game logic.Blackjack
: ExtendsGame
with specific logic for Blackjack.
The project includes unit tests to ensure the reliability of key functionalities like card handling, deck operations, and game logic.
Tests are implemented using Jest. To run the tests, execute:
npm test
The Blackjack project is open-sourced under the MIT license.