← Questions
Design a poker game
0
I was asked this
No reports yet. Sign in to say where you were asked it.
An object-oriented design interview question asked in Google's onsite coding round, last asked Jan 2026. It tests object-oriented design and games.
Design the object model for a poker game, for example Texas Hold'em: cards and a deck, players and their chips, the betting rounds, and deciding the winner at showdown. Name the main classes and their responsibilities, then implement the parts the interviewer asks for, usually dealing and hand comparison.
Requirements
- Functional:
- A 52-card deck that can be shuffled (with an injectable random source for tests) and dealt.
- Players join a table with chips; a hand moves through blinds, pre-flop, flop, turn, river and showdown.
- Betting actions: fold, check, call, bet, raise, all-in; a pot, and side pots when someone is all-in.
- Evaluate each player's best five-card hand and decide the winner or a split pot, deterministically.
- Non-functional: rules isolated so other variants (Omaha, five-card draw) can reuse the model; the game logic is testable without a UI.
Clarifying questions
- Which variant, and how many players?
- Is betting in scope, or only dealing and hand comparison?
- Do we need side pots and split pots?
- Is this for a single process, or a networked game with many tables?
What a strong answer covers
- Classes:
Card(rank, suit, value objects),Deck,Player(name, chips, hole cards, status),TableorGame(seats, dealer button, blinds),RoundorHand(the state machine of betting streets),Pot(with side pots),HandEvaluatorand a comparableHandRank. - Hand ranking: categories from high card to straight flush, with tie-breaks by ranks in order; the ace-low straight; choosing the best 5 of 7 cards.
- The flow of one hand as a state machine, with validation of whose turn it is and which actions are legal.
- Extensibility: variant rules behind an interface (how many hole cards, community cards, streets), evaluation separate from game flow.
- Tests: fixed decks to make hands deterministic, ties and split pots.
Follow-ups
- Add side pots for several all-in players with different stacks.
- Make hand evaluation fast enough to simulate millions of hands.
- Run many tables over a network: what state lives on the server, and how do you handle a player disconnecting?
Where it's asked
- Google · Onsite coding · Last asked Jan 202645 min · Usually two rounds, mostly in person: whiteboard plus a Chromebook with Google Docs · No AI (a pilot code-comprehension round lets candidates use Gemini)
What it tests
object-oriented design · games
No official answer yet. Draw yours on the right; publish it and it shows under Community.
Nothing published yet. Publish your canvas and it shows here for others to open and remix.
Draw your answer hereBoxes, arrows and notes, saved for you to come back to.Sign in to start drawing
