Model a Card Deck Reusable Across Different Card Games

Last updated: November 29, 2026

Quick Overview

Design classes for a standard deck that support shuffling, dealing, and multi-deck shoes, and show how game-specific rules such as blackjack hand scoring stay separate from the deck itself.

Google
Software Engineering Fundamentals
Software Engineer
Google
November 29, 2026
Software Engineer
Phone Screen
Software Engineering Fundamentals
Easy

0

0

0 solved


Design classes for a standard deck that support shuffling, dealing, and multi-deck shoes, and show how game-specific rules such as blackjack hand scoring stay separate from the deck itself.

A classic Google phone-screen OOD question for early-career candidates, often extended with a scoring rule. The interviewer looks for value objects, separation of generic and game-specific logic, injectable randomness for tests, and a correct shuffle.

What the Interviewer Expects
  • Models Card as an immutable value object
  • Keeps Deck generic and puts scoring in a separate class
  • Uses a proper Fisher-Yates shuffle rather than sorting by random keys
  • Injects a random generator for reproducible tests
  • Handles dealing more cards than remain
Key Topics to Cover
value objects
separation of concerns
Fisher-Yates shuffle
dependency injection
OOD
How to Approach This
  1. Apply SOLID principles. Single Responsibility makes code testable, Open/Closed makes it extensible.
  2. Choose data structures based on access patterns, not familiarity.
  3. Prefer immutable data and message passing over shared mutable state for concurrency.
  4. Design APIs with RESTful conventions, versioning, meaningful errors, and pagination from day one.
Possible Follow-up Questions
  • How would you support jokers or a non-French deck?
  • How would you prove your shuffle is unbiased?
  • How would you model a full blackjack table with players and a dealer?
Sharpen Your Skills on Codemia

Practice similar problems with our interactive workspace, get AI feedback, and track your progress.

Practice System Design Problems
Sample Answer
Requirements
  • Cards have rank and suit, are immutable and hashable.
  • Deck supports shuffle, deal(n), remaining, and multiple decks.
  • At least one game rule (blackjack scoring) built on top without changin...
High-Level Design

Card is a frozen dataclass so it can go in sets and dict keys. Deck owns a list of cards plus a discard pile and an injected random.Random. Dealing takes from the end of the list in O(n). `Black...


Submit Your Answer
Markdown supported