This is a bowling scorecard, that tracks the scores in a game of bowling. I have built this using a TDD approach in Javascript and have used jasmine as the testing framework.
The specification is below:
- The game starts at 0
- A player rolls a gutter game if they role 20 balls without knocking any down
- There are 10 frames with 2 bowls per frame, unless the player bowls a strike (in which case there is 1 bowl for that frame)
- The player has a spare if the knocks down all 10 pins with the two rolls of a frame. The bonus for that frame is the number of pins knocked down by the next roll (first roll of next frame).
- The player has a strike if he knocks down all 10 pins with the first roll in a frame. The frame ends immediately (since there are no pins left for a second roll). The bonus for that frame is the number of pins knocked down by the next two rolls. That would be the next frame, unless the player rolls another strike.
- If a player bowls a strike in the 10th frame, they will get another go. This applies in the 11th frame, but the player can have no more than 12 frames.
- A perfect game is bowled with a final score of 300.
- A gutter game is bowled with a final score of 0.
- Run the command in the folder you would like to store this app
git clone https://github.com/samkitchen94/bowling-challenge.git
- In the relevant folder in the command line, run
open SpecRunner.html
This will show you the passing tests in a browser
- Next open the console within the browser and here you can interact with the code
As soon as I get more time an interface will be added to this so that the user can open this within their browser and input their own scores when bowling. The scorecard will calculate their scores and take into account any spares, strikes etc.
This will be done using jQuery.
- Challenge time: rest of the day and weekend.
- Feel free to use google, your notes, books, etc. but work on your own
- If you refer to the solution of another coach or student, please put a link to that in your README
- If you have a partial solution, still check in a partial solution
- You must submit a pull request to this repo with your code by 9am Monday week
THIS IS NOT A BOWLING GAME, IT IS A BOWLING SCORECARD. DO NOT GENERATE RANDOM ROLLS. THE USER INPUTS THE ROLLS.
Count and sum the scores of a bowling game for one player (in JavaScript).
A bowling game consists of 10 frames in which the player tries to knock down the 10 pins. In every frame the player can roll one or two times. The actual number depends on strikes and spares. The score of a frame is the number of knocked down pins plus bonuses for strikes and spares. After every frame the 10 pins are reset.
As usual please start by
-
Forking this repo
-
Finally submit a pull request before Monday week at 9am with your solution or partial solution. However much or little amount of code you wrote please please please submit a pull request before Monday week at 9am. And since next week is lab week you have a full extra week to work on this.
STRONG HINT, IGNORE AT YOUR PERIL: Bowling is a deceptively complex game. Careful thought and thorough diagramming — both before and throughout — will save you literal hours of your life.
In any order you like:
- Create a nice interactive animated interface with jQuery.
- Set up Travis CI to run your tests.
- Add ESLint to your codebase and make your code conform.
You might even want to start with ESLint early on in your work — to help you learn Javascript conventions as you go along.
The player has a strike if he knocks down all 10 pins with the first roll in a frame. The frame ends immediately (since there are no pins left for a second roll). The bonus for that frame is the number of pins knocked down by the next two rolls. That would be the next frame, unless the player rolls another strike.
The player has a spare if the knocks down all 10 pins with the two rolls of a frame. The bonus for that frame is the number of pins knocked down by the next roll (first roll of next frame).
If the player rolls a strike or spare in the 10th frame they can roll the additional balls for the bonus. But they can never roll more than 3 balls in the 10th frame. The additional rolls only count for the bonus not for the regular frame count.
10, 10, 10 in the 10th frame gives 30 points (10 points for the regular first strike and 20 points for the bonus).
1, 9, 10 in the 10th frame gives 20 points (10 points for the regular spare and 10 points for the bonus).
A Gutter Game is when the player never hits a pin (20 zero scores).
A Perfect Game is when the player rolls 12 strikes (10 regular strikes and 2 strikes for the bonus in the 10th frame). The Perfect Game scores 300 points.
In the image below you can find some score examples.
More about ten pin bowling here: http://en.wikipedia.org/wiki/Ten-pin_bowling
In code review we'll be hoping to see:
- All tests passing
- The code is elegant: every class has a clear responsibility, methods are short etc.
Reviewers will potentially be using this code review rubric. Note that referring to this rubric in advance may make the challenge somewhat easier. You should be the judge of how much challenge you want.