Skip to content

Latest commit

 

History

History
127 lines (95 loc) · 3.55 KB

README.md

File metadata and controls

127 lines (95 loc) · 3.55 KB

URUG Bowling Game Kata Exercise

what is a kata? (from http://codekata.com/)

####A kata is an exercise in karate where you repeat a form many, many times, making little improvements in each.

There are many exercises and challenges that are used as short katas to help programmers improve their craft. We are going to use one of Uncle Bob's favorite katas, the bowling game, to gain some experience with TDD and using it for problem solving. This exercise has been designed in a TDD format by utilizing a premade repositor of tests. Each stage of the kata is tagged in a git repository found at git remote add origin https://github.com/urug/2017_bowling_game.git.

Pull the repo to your local development environment and checkout the first tag (v0.1). You will need to have the minitest and minitest-reporters gem installed. Run the test suite with "ruby game_test.rb" and go to work to make the test pass. Once it passes you can refactor and then checkout the next tag. Here is the list of tags:

v0.1 - Initial checkin - all gutter balls

v0.2 - all static rolls 1

v0.3 - all static rolls 2

v0.4 - all static rolls 3

v0.5 - single spare roll

v0.6 - 9 spare rolls

v0.7 - all spare rolls

v0.8 - one strike

v0.9 - nine strikes

v1.0 - all strikes

With these tests in place you don't even need to know how to score bowling. In case you're interested, here are the rules and an example:

The game consists of 10 frames (or turns) as shown above. In each frame the player has two opportunities to knock down 10 pins. The score for the frame is the total number of pins knocked down, plus bonuses for strikes and spares.

A spare is when the player knocks down all 10 pins in two tries. The bonus for that frame is the number of pins knocked down by the next roll. So in frame 3 above, the score is 10 (the total number knock>>ed down) plus a bonus of 5 (the number of pins knocked down on the next roll.)

A strike is when the player knocks down all 10 pins on his first try. The bonus for that frame is the value of the next two balls rolled.

In the tenth frame a player who rolls a spare or strike is allowed to roll the extra balls to complete the frame. However no more than three balls can be rolled in tenth frame.

##bowling game example: ####frame 1

roll 1: 1
roll 2: 4
score: 5

####frame 2

roll 1: 4
roll 2: 5
score: 14

####frame 3

roll 1: 6
roll 2: 4 (spare)
score: 29

####frame 4

roll 1: 5
roll 2: 5 (spare)
score: 49

####frame 5

roll 1: 10 (strike)
score: 60

####frame 6

roll 1: 0
roll 2: 1
score: 61

####frame 7

roll 1: 7
roll 2: 3 (spare)
score: 77

####frame 8

roll 1: 6
roll 2: 4 (spare)
score: 97

####frame 9:

roll 1: 10 (strike)
score: 117

####frame 10:

roll 1: 2
roll 2: 8 (spare)
roll 3: 6 ###score: 133

###PROGRAMMING NOTES:

  1. you may assume that all rolls are valid >>a. no frames will amount to more than 10 pins
    >>b. there will be exactly the correct number of rolls made for the game
    >>c. you don't need to account for invalid roll parameters (i.e. negative numbers etc.)
  2. the score method will not be called until all rolls for a game have been made
  3. Work in pairs and use TDD to build your solution. Our tests are using minitest so it will be easiest if you use that in your work.
  4. We have supplied the Gemfile that we used to build our solution, this should be all you need to complete the challenge.

##Go for it and have fun!