This repository forms part of the ONS Software Development Practices engineering training sessions. It contains a base project to run the bowling game kata from.
masteran empty project which can be used to practice/demonstrate the katacompleteda branch with the completed code and a commit history detailing each step.
The bowling game kata is a well know code kata. The aim is to use TDD to implement a class which calculates the score of a 10 pin bowling game. The class should have the following interface:
class BowlingGame:
def roll(self, pins):
"""
Call this each time a ball is rolled passing in the number of pins that
were knocked down.
"""
def score(self):
"""
Call this at the end of the game to get the final score.
"""- A game has
10frames - A player has
2rolls per frame to try and knock down all10pins - If a player knocks down all
10pins in a frame then they score aspare:- The score for a
spareis the10pins plus the next roll as a bonus
- The score for a
- If a player knocks down all
10pins in the first roll of a frame then they score astrike:- If a
strikeis scored then there is no second roll in the frame - The score for a
strikeis the10pins plus the next2rolls as a bonus - If a
strikeis scored in the last frame then2bonus rolls are added to the frame
- If a
- A perfect game is
12successivestrikesand scores300points
For a real implementation of this you would want to check for errors, including the following:
- Negative number of pins passed to
roll - More than
10pins passed toroll - Score called before the game is completed
- Roll called too many times
However, for this demonstration we are only focussing on the happy path.