GithubHelp home page GithubHelp logo

tdd-exercise's Introduction

TDD Exercise

In this exercise you will write a method and set of tests in TDD fashion which calculates a hand's BlackJack score.

About BlackJack

In the card BlackJack each card has a value.

  • Number cards (2-10) carry the card's numeric value.
  • Face cards on the other hand ("Jack", "Queen", "King") have a value of 10.
  • Aces (1) can have a value of either 1 or 11, whichever will get the hand closest to 21 without going over.

For example if I had a 3, a King, and an Ace, my BlackJack score is 14 (3 + 10 + 1). If I have an Ace, and a Jack then my score is 21 (11 + 10).

A hand, an array of Card values, must be between 2 and 5 items inclusive.

When a hand's score is greater than 21, the hand is a bust and the player automatically loses.

Part 1: Identifying Edge & Nominal Cases

With a partner talk through the following questions and write down answers.

  1. What would be two nominal cases?
  2. What edge cases can you determine? Name at least 3.
  3. How would you test these cases?

When you finish talk with another pair and walk through your answers.

Part 2: Calculating a Score

You will write a method called: blackjack_score which take an array of card values and returns the blackjack score. The card values can be any of the following, number values 1-9, "King", "Queen", "Jack". If the array contains an invalid card value or the total exceeds 21, raise an ArgumentError. For example blackjack_score([1, 5, 3]) will return 19. You should also raise an error if the hand contains more than 5 cards.

In this exercise you will complete the given tests in specs/blackjack_score_specs.rb and updating the blackjack_score method in lib/blackjack_score.rb to make it pass.

Step 1: Complete the given test Step 2: Update blackjack_score to pass the test Step 3: Move to the next test

tdd-exercise's People

Contributors

cheezitman avatar goblineer avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.