A card game models cards, a deck, and rules for dealing and scoring. In a Blackjack implementation, each card stores a suit and face, while collections track available cards and game state. section 26.1
A practical card-game model handles the following:
- Store suits and faces in Sets, and map most face names to numeric values. section 26.1
- Create a 52-card deck, shuffle it through an array, then restore the shuffled cards to the Set. section 26.1
- Track whether cards are face up, remove cards when dealing, and count aces as either 1 or 11. section 26.1
Creating and dealing a deck
Create every suit-and-face combination, shuffle the deck, then deal an initial hand by popping two cards. Each popped card is marked face up and removed from the deck.
