This project provides an implementation of a standard deck of playing cards for a game of Blackjack. The deck includes the following functionalities:
- Creation of a new deck with 52 unique cards, each having a suit (Hearts, Diamonds, Spades, Clubs) and a face/pip (Ace, 2-10, Jack, Queen, King).
- Methods to shuffle the deck and deal a card from the deck.
- Unit tests to validate the functionality of the deck.
- Deck Creation: A method to create a new deck with 52 unique cards.
- Shuffling: A method to shuffle the deck.
- Dealing: A method to deal a card from the deck.
-
A standard deck of playing cards containing:
- A suit (Hearts, Diamonds, Spades, Clubs)
- A face/pip (Ace, 2-10, Jack, Queen, King)
- 52 unique cards with all 13 faces from all four suits
-
Methods to:
- Create a new deck
- Shuffle the deck
- Deal a card from the deck
-
Unit tests to validate:
- A deck contains 52 cards with no duplicates
- The order of cards is different after being shuffled
- The number of cards available after dealing cards is reduced
IDeck: Interface for deck operations.IDeckFactory: Interface for creating a deck.IShuffler: Interface for shuffling a deck.IDealer: Interface for dealing a card from the deck.
Deck: ImplementsIDeck, manages the deck of cards usingIDeckFactory,IShuffler, andIDealer.DeckFactory: ImplementsIDeckFactory, responsible for creating a new deck of cards.Shuffler: ImplementsIShuffler, responsible for shuffling the deck of cards.Dealer: ImplementsIDealer, responsible for dealing a card from the deck.
The unit tests validate the functionality of the Deck class, ensuring the deck contains 52 unique cards, shuffles correctly, and deals cards as expected.
- DeckContains52CardsWithNoDuplicates: Validates that a deck contains 52 unique cards.
- OrderOfCardsIsDifferentAfterBeingShuffled: Ensures the order of cards is different after shuffling.
- NumberOfCardsAvailableAfterDealingIsReduced: Verifies that the number of cards in the deck is reduced by one after dealing a card.
- DealtCardIsRemovedFromDeck: Confirms that the dealt card is removed from the deck.
- Ensure you have the .NET SDK installed on your machine.
- Clone the repository.
- Navigate to the project directory.
- Run the tests using the following command:
dotnet test