For my first project in my delve into software development, I was tasked with creating a CLI application. My partner, Jonathan Hakimian, and I decided on creating the classic game of Blackjack. We called it HackJack! Here’s how it felt along the way of building my first project!
What is Blackjack and how do you play it?
Blackjack, or 21, is a gambling game that uses one deck of cards. The goal of the game is to get as close as possible to 21 (not over!) as the dealer flips over your cards. The numbered cards (2 through 10) are worth their face value, the face cards (Jack, Queen, King) are worth 10, and an Ace is worth 1 or 11, depending on your other cards. To start, players place a bet and are dealt two cards face up. They can choose to “Hit” or “Stay” (receive another card or stay with current hand, respectively). If players choose to hit and go over 21, they “bust” and lose the bet and game! The players play against a dealer who starts with one card faced up and one card faced down. Once the player stays, the dealer’s turn starts. If the dealer goes over 21, they bust and the player earns back the bet.
This game is a classic object-oriented programming relationship. We have 3 classes: User, Round, and Dealer. Thinking about the classes was easy at first. Then, confusing. Then, back to easy. When thinking about the actual game (we called it Round in our application), we felt wildly confused about having to create classes for the Users hand, Dealers hand, Cards, and the Deck. But, in the nick of time, we found a DeckOfCards gem (linked here) that made the application and our heads, stop spinning and we got to work.
These are the user stories my partner and I created for our game. User stories are actions you want a user to have when using your application. Even in a simple application like a CLI game, creating user stories is a great way to get started. It helps you understand how you want the application to run for the user and therefore, create a user-friendly application!
Set Up The Environment
The first thing we did, was set up the environment. We created 4 models: User, Round, Dealer, and HackJack. We also figured out what we wanted to save for each model in our database tables; the HackJack model was our model for the CLI game, so it doesn’t have a table, but below you’ll find the column_names we used to create our database tables. We also decided we wanted to try out a few gems: TTY-Toolkit, Faker, ArtII, Pastel, and Colorize.
The best part of building this game was a week’s worth of pair programming. My partner and I decided to write about 95% of the app together, so we spent most of the week on Zoom, sharing screens and learning the nuances of git workflow.
Throughout the week, there were so many times I was grateful to have a partner. Without a partner, some bugs that came up would’ve taken me hours or even days. But with a partner, we were able to fix every bug in minutes! Working together definitely comes with some guidelines, but it makes coding feel that much more empowering.
My top tips in pair programming are:
- check your ego at the door
- Always respond with “yes, and…”
- Consider every option and explain your why
Here’s the link to our repo on GitHub. Download it and take a look! It was so much fun to code :)