Design a Deck, Hand, and Dealer
Model a standard card deck with deterministic shuffle, atomic dealing and exchanges, and read-only comparison of five-card hands.
Design the low-level object model and interfaces for a Deck, Hand, and Dealer.
For this exercise, assume one fixed standard 52-card deck, deterministic test randomness, multiple player hands, and a dealer that can exchange selected hand cards for remaining deck cards. Every physical card has a stable CardId and exactly one owner: undealt deck, dealer discard, or one hand.
Every deal or exchange transfers all involved CardIds atomically; the candidate chooses the aggregate boundary.
For invalid states, return explicit outcomes for: insufficient undealt cards; unknown or unowned CardId during exchange; duplicate CardId in one exchange request.
Preserve this invariant: Every CardId appears in exactly one of undealt deck, one hand, or discard after every atomic transition by the candidate-chosen owning aggregate.
Also design comparison of five-card hands. For this exercise, assume the standard five-card poker categories, strongest first: straight flush, four of a kind, full house, flush, straight, three of a kind, two pair, one pair, high card.
Within a category, compare the relevant rank vector lexicographically: straight/straight flush by highest straight rank; four of a kind by quad rank then kicker; full house by triple then pair; flush/high card by all ranks descending; three of a kind by triple then descending kickers; two pair by higher pair, lower pair, then kicker; one pair by pair then descending kickers.
Ace is high except the A-2-3-4-5 straight, which has high rank 5. Suits and physical CardIds never break an otherwise equal rank tie.
For this exercise, assume comparing two hands reads a consistent read-only view of their cards and reports whether the first hand wins, the second hand wins, or they tie, with no ownership mutation. Equivalent operation names, result names, and coherent responsibility boundaries are valid.
Each compared hand must contain exactly five cards. Unknown hands, a hand of another size, or an unsupported ranking configuration produce explicit errors and no state change.
The base game has no jokers; multiple-deck or joker comparison requires a separately validated policy rather than silently reusing the base policy. Keep the existing shuffle implementation checkpoint and atomic deal/exchange requirements.