A command-line based card game built with Python, demonstrating solid Object-Oriented Programming principles and test-driven development using unittest.
card.py– Defines theCardclass, representing a single playing card.deck_of_cards.py– Manages theDeckOfCardsclass, including deck creation, shuffling, and drawing.player.py– Contains thePlayerclass, handling player hands and actions.card_game.py– Main game logic class that simulates a round-based card game between two players.test_*.py– Unit tests for each main component.
- Fully modular OOP structure (Card, Deck, Player, Game)
- CLI-based gameplay simulation
- Randomized deck with shuffling and drawing
- Robust edge case handling (e.g., empty deck, insufficient cards)
- 100% unit test coverage for key components
- TDD development approach using Python’s built-in
unittestlibrary
python -m unittest discover- Python 3.x
unittestrandommodule- Command Line Interface (CLI)
- Deepen understanding of class relationships and encapsulation
- Practice TDD (Test-Driven Development)
- Handle game logic, state management, and input validation
- Organize a clean and testable Python codebase