Blackjack

Readme Homework


Episode1 Summer 2012- BlackJack

A Casino game. No gambling, just skill!

Panda Level

  1. Play the game by running this code:
irb
require "./blackjack"
game = Game.new
game.hit
game.stand
  1. Change the Card's to_s to show "QH" instead of queen-hearts". And "5H" instead of 5-hearts

Tiger Level

  1. Complete the Panda assignment
  2. If a player busts (goes over 21), the game should #standfor the player

Eagle Level

  1. The dealer hand should not not show both cards until the player has stood (It should be like "XX", "5H")

Copyright: Jesse Wolgamott, MIT License (See LICENSE)

Blackjack

  • Area:

    Databases  
  • Runtime:

    1:03  
  • Tech:

    Ruby, RSpec  
  • Tags:

    rspec tdd games  

We're starting the course off with a well-known game: Blackjack. It's a simple'ish game: 2 cards for the Dealer, 2 cards for the User with the option for more cards, if closest to 21 without going over wins. Of course, if you play blackjack, you know there's more too it then that.

A number of you haven't written any tests before, so it may come as somewhat of a shock. Here's one reason I think Ruby has such a test driven culture:

Ruby doesn't have static typing, and the code can twist itself and change itself at run-time. So, the only way to guarantee that code is going to stay correct today and in the future is to write tests that check for behavior and correctness. A well crafted and full test-suite is a thing of beauty. It holds you safe at night and makes the hard to comprehend comprehendible.

Creative Commons License
This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.

ABOUT RUBY OFF RAILS

Ruby Off Rails is dedicated to accelerating the mastering of Ruby and increasing developer happiness everywhere.

In my software training, I see two distinct sets of programmers: those who know Ruby, and those who haven’t learned it yet. People who learn Ruby have an easier time understanding Rails, gems, and what magic voodoo is going on. And most importantly, they can cast wicked voodoo themselves.