{"id":15619788,"url":"https://github.com/drbragg/blackjack","last_synced_at":"2026-05-18T21:30:14.613Z","repository":{"id":122870105,"uuid":"98449005","full_name":"DRBragg/blackjack","owner":"DRBragg","description":"First ruby project for Launch Academy","archived":false,"fork":false,"pushed_at":"2017-07-27T13:17:37.000Z","size":6,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-01-02T17:22:05.561Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/DRBragg.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-07-26T17:32:23.000Z","updated_at":"2017-07-26T17:34:53.000Z","dependencies_parsed_at":null,"dependency_job_id":"697ece11-176a-4e42-b295-89e26e04bbf4","html_url":"https://github.com/DRBragg/blackjack","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DRBragg%2Fblackjack","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DRBragg%2Fblackjack/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DRBragg%2Fblackjack/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DRBragg%2Fblackjack/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/DRBragg","download_url":"https://codeload.github.com/DRBragg/blackjack/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240125152,"owners_count":19751651,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-03T08:41:38.475Z","updated_at":"2026-05-18T21:30:14.549Z","avatar_url":"https://github.com/DRBragg.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"## Introduction\n\nBlackjack is a card game between a player and the dealer using a deck of 52 cards. The object of the game is to reach a score as close to 21 as possible without exceeding it (bust). Both the dealer and the player are initially dealt two cards and have the option to receive another card (hit) or keep their current score (stand). The player can continually hit until they score 21 or bust. A dealer is required to stand when their score is between 17 and 21, inclusive.\n\nA score is calculated by adding up the ranks of the cards in a player's hand.\n\n* Face cards (Jack, Queen, King) are worth 10 points\n* Aces are worth either 11 points or 1 point, whichever value yields the best score.\n* Every other card is worth its face value.\n\nThe player is dealt first and continues to play until they bust or stand. Once a player stands, the dealer will then play until they bust or stand. If a player busts, the dealer wins. If the dealer busts, the player wins. If neither busts, whoever has the score closest to 21 wins. In case of a tie, neither the player nor the dealer wins.\n\n## Learning Goals\n\n* Practice problem decomposition and problem simplification.\n* Write a program that utilizes multiple classes in separate files.\n* Practice **object composition** (objects using objects).\n\n## Instructions\n\nWrite a program where the user can play a game of **Blackjack**. Define and use the following classes to organize your code:\n\n* `Card` to represent an individual playing card. This class should contain the suit and the value and provide methods for determining what type of card it is (e.g. face card or ace). Write the code to implement this class in `lib/card.rb`.\n* `Deck` to represent a collection of 52 cards. When dealing a hand this class can be used to supply the `Card` objects. Write the code to implement this class in `lib/Deck.rb`.\n* `Hand` to represent the player's and dealer's hand. This class will need to determine the best score based on the cards that have been dealt. Write the code to implement this class in `lib/hand.rb`.\n* `lib/blackjack.rb` will contain code to interact with the classes you write and it will handle the logic of the game.\n\n\n## Managing Problem Complexity with User Stories\n\nThe game of Blackjack, as it is played in a casino, is quite complex. The game involves betting, the possibility of \"splitting\" a hand into two separate hands, allowing the player to buy \"insurance\" when the dealer is showing an ace, as well as many other **special cases** which make up the game.\n\nWe can simplify the complex problem of Blackjack by describing the gameplay in the form of **user stories**. The goal of a well-written user story is to describe how a user will interact with the software. We can describe the special cases as user stories which could be completed at a later date (or not at all).\n\n**Focus on implementing one user story at a time.** This is how professional software developers manage the complexity of large software projects.\n\nThe program should satisfy the following user stories:\n\n#### Deal initial hand\n\n```no-highlight\nAs a dealer\nI want to initially deal out two cards to the current player\nSo that we can begin the game\n```\n\nAcceptance Criteria:\n\n* Cards are dealt from a shuffled deck of 52 cards.\n* Output `Player was dealt CARD` for each card the player receives.\n* Output `Dealer was dealt CARD` for each card the dealer receives.\n\n#### Prompt for input\n\n```no-highlight\nAs a player\nI want to be prompted to hit or stand\nSo that I know when I have to act\n```\n\nAcceptance Criteria:\n\n* Prompt the player to hit or stand after they receive their initial hand.\n* Continue prompting unless the player stands or busts.\n* Output `Hit or stand (H/S): ` and read the user input on the same line.\n* Notify the user when the input is invalid (neither hit or stand) and re-prompt.\n* Allow uppercase or lowercase characters as user input.\n\n#### Display score\n\n```no-highlight\nAs a player\nI want to know my current best possible score\nSo that I can decide whether to hit or stand\n```\n\nAcceptance Criteria:\n* Display the player's score each time they have to hit or stand.\n* Output `Players score: SCORE` on a separate line.\n* Aces should count as one or eleven, whichever is closest to 21 without going over.\n\n#### Player hits\n\n```no-highlight\nAs a player\nI want to hit\nSo that I can increase my score\n```\n\nAcceptance Criteria:\n\n* \"Hit\" takes another card from the deck and places it in the player's hand.\n* The player's best possible score should be recalculated and displayed again.\n* If the player busts, output `Bust! Game over...` and exit the game.\n\n#### Player stands\n\n```no-highlight\nAs a player\nI want to stand\nSo that I don't bust\n```\n\nAcceptance Criteria:\n\n* \"Stand\" will end the player's turn and begin the dealer's turn.\n* The player's best possible score should be recalculated and displayed again.\n\n#### Dealer hits until score threshold\n\n```no-highlight\nAs a dealer\nI want to continue hitting until my score is at least 17\nSo that I get close to 21 without too much risk of busting.\n```\n\nAcceptance Criteria:\n\n* While the dealer's best possible hand is below 17, continue hitting.\n* If the dealer's lowest score exceeds 21, output `Bust! You win!`.\n\n## Sample Output\n\n```no-highlight\n$ ./blackjack.rb\nWelcome to Blackjack!\n\nPlayer was dealt 10♦\nPlayer was dealt A♣\nPlayer score: 21\n\nHit or stand (H/S): s\n\nPlayer score: 21\n\n\nDealer was dealt Q♠\nDealer was dealt 8♥\nDealer score: 18\n\nDealer stands.\n\nYou win!\n```\n\n```no-highlight\n$ ./blackjack.rb\nWelcome to Blackjack!\n\nPlayer was dealt 7♦\nPlayer was dealt 5♥\nPlayer score: 12\n\nHit or stand (H/S): h\n\nPlayer was dealt 2♥\nPlayer score: 14\n\nHit or stand (H/S): h\n\nPlayer was dealt J♠\nPlayer score: 24\n\nBust! You lose...\n```\n\n### Tips\n\nSince Aces are a special case, it is helpful to simplify the problem. Make Aces\nworth 11 points. When you get the basic functionality of the application\nworking, _then_ attempt to solve the problem of handling Ace scoring. This is a\ncommon strategy when problem solving with code: get the code working for a\nsimple case, then move on to the more complex cases.\n\nIt is not required, but it is recommended that you write unit tests for your\nclasses.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdrbragg%2Fblackjack","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdrbragg%2Fblackjack","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdrbragg%2Fblackjack/lists"}