This JavaScript app simulates a bowling scorecard, allowing a user to enter their scores per roll, and calculating the running total.
- JavaScript
- Jasmine
- Further improve my test-driving of heavy logic-based problems
- Further learn JavaScript
- Improve my process of learning new languages
-
Fork this repo
-
git clone git@github.com:<userName>/bowling-challenge
onto your local machine
After forking and cloning repo, open the path to SpecRunner.html
in your browser.
Click ok
to any tests that prompt alerts.
Copy the path to index.html
into your browser, and start adding scores
Alternatively, console commands can be used as follows (examples showing scoring variations and strike/spare bonuses)...
scorecard = new Scorecard
frame1 = new Frame
frame1.enterFirstRollScore(10, scorecard)
frame2 = new Frame
frame2.enterFirstRollScore(10, scorecard)
frame3 = new Frame
frame3.enterFirstRollScore(6, scorecard)
frame3.enterSecondRollScore(6, scorecard)
// => Frame.js:39 Uncaught Error: A maximum of 10 can be scored per frame.
frame3.enterSecondRollScore(4, scorecard)
frame4 = new Frame
frame4.enterFirstRollScore(7, scorecard)
frame4.enterSecondRollScore(1, scorecard)
scorecard
// returns...
Scorecard {frames: Array(4)}
frames: Array(4)
0: Frame
bonusScore: 16
firstRollScore: 10
secondRollScore: 0
spareFlag: false
strikeFlag: true
totalScore: 26
__proto__: Object
1: Frame
bonusScore: 10
firstRollScore: 10
secondRollScore: 0
spareFlag: false
strikeFlag: true
totalScore: 20
__proto__: Object
2: Frame
bonusScore: 7
firstRollScore: 6
secondRollScore: 4
spareFlag: true
strikeFlag: false
totalScore: 17
__proto__: Object
3: Frame
bonusScore: 0
firstRollScore: 7
secondRollScore: 1
spareFlag: false
strikeFlag: false
totalScore: 8
__proto__: Object
length: 4
scorecard.calculateTotalScore()
// => 71
Links to requirements and problem breakdown, and models
Link to first roll logic flow model
Link to second roll logic flow model
-
A bowling game consists of 10 frames.
-
In each frame the player tries to knock down the 10 pins
-
The player can roll one or two times per frame, depending on whether the player has scored a
strike
. -
The score of a frame is the number of knocked down pins plus bonuses for a
strike
orspare
. -
After every frame the 10 pins are reset.
-
The player has a
strike
if they knock 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 (the 2 rolls of the the next frame, unless the player rolls another strike).
-
The player has a spare if they knock down all 10 pins with their two rolls in 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 additional balls for the bonus
-
If a
spare
, the player rolls one more for the bonus. -
If a
strike
, the player rolls two more for the bonus. -
These additional rolls only count for the bonus
-
10
| 10
| 10
=> 30 points (10 points for the regular first strike and 20 points for the bonus).
1
| 9
| 10
=> 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.
- Create an interactive animated interface with jQuery.
- Set up Travis CI to run tests.
- Add ESLint to codebase and make code conform.