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