Plan how to create a game of blackjack.
After completing this assignment, you should understand:
- Object-oriented design.
After completing this assignment, you should be able to:
- Design a system using responsibilities and collaborators.
- Turn your design into objects.
- A Git repo called blackjack containing at least:
- a
README.md
file explaining your design. - a
blackjack
directory with a file for each of your classes, with their responsibilities and collaborators described in a comment - a completed Card and Deck class
- tests for Cards and Decks
- a
- Passing unit tests
- No PEP8 or Pyflakes warnings or errors
- Use the project layout from The Hacker's Guide to Python
Read through the rules of blackjack carefully. After reading through them, write out the steps to run the game in outline format. (See the additional resources for more on the rules of blackjack.)
After that, go through your steps and find all the actors -- that is, nouns
that take actions. Create class-responsibility-collaborator (CRC) cards for
each and then create empty classes for each of them with the responsibilities
and collaborators at the top as a comment. Here is an example that you might
find in blackjack/card.py
:
class Card:
"""A playing card.
Responsibilities:
* Has a rank and a suit.
* Has a point value. Aces point values depend on the Hand.
Collaborators:
* Collected into a Deck.
* Collected into a Hand for each player and a Hand for the dealer.
"""
Lastly, implement the Card
and Deck
classes.