/Blackjack_CLI

A CLI Blackjack game in Python

Primary LanguagePython

Python Blackjack Game

This is a CLI Blackjack game in Python.

To run this app, make sure you installed python on your computer. If so, open the terminal and type in

python blackjack.py

What assumptions/choices you made to overcome any lack of clarity you found in the instructions

N/A

What you did well on this project

  • Used object-oriented design for better clarity and followed design principle.
  • Visulization of the card to make the game more realistic

Rationale on design choices, algorithmic decisions made

  • Using classes instead of writing a long script to achieve better readability and thus make it open to modification.

  • Build a Card class to store all the card options and their values and a Player class which can represent both the dealer and the player. These are obvious design choices. When it comes to the action of player drawing the card, there are two options:

    1. Build the functions inside of the Player class since it's the player's activity;
    2. Build a seperate class to store the current result.

    I chose the latter because of the Single Responsibility Principle. The Player class should focus on the player's activity, like hit and stand. Storing the current cards and scores in a seperate class would achieve that.

Tradeoffs you encountered while programming and how you resolved them

One tradeoff is create a different function to show cards of the dealer when the player is still in play. My original thought was to use one class to represent both player and dealer, since their actions are mostly the same. However, the game would require the second card of the dealer remain marked before the player stands. Given limited time, the most efficient way is to add another function simply for this feature.

What you would improve on this project given more time

  • I would create an interface User and let dealer and player implement the interface to avoid setting a seperate function only for the dealer in the Player class.
  • The visualization seems very crowded if there exists many rounds. Maybe I would add some highlight symbols to make it more readable.

What manual tests you ran on the code

I typed the command in the terminal to see if the code compiles and runs successfully. After that, I tried to play several times and fixed some bugs I didn't notice earlier.

How to run any automated tests you created

I would write another function with hardcode corner case examples to test the robustness of my code.