Write a program that counts and sums the scores of a bowling game for a single player.
- 1 player only
- There are 10 pins in a frame
- The objective in each frame is for the player to knock down all the pins
- A player is allowed a maximum 2 rolls per frame
- There are 10 frames in a single game
- The highest score possible is 300
- If in a single frame, the player is unable to knock down all the pins, the score for the frame is the sum of the 2 rolls
- i.e. if the player rolls 5,4 then the score is 5 + 4 = 9
- If in a single frame, the player is able to knock down all the pins with 2 rolls, the player has scored a spare.
- the score for a space is the sum of the number of pins knocked down + the number of pins knocked down in the next roll
- i.e. if the player rolls 4,6 | 5,0 then the score is 4 + 6 + 5 = 15 and 5 + 0 = 5 over the 2 frames
- If in a single frame, the player is able to knock down all the pins with the 1st roll, the player has scored a strike
- the score for a strike is the sum of the number of pins knocked down + the number of pins knocked down in the next 2 rolls
- i.e. if the player rolls 10 | 5,4 then the score is 10 + 5 + 4 = 19 and 5 + 4 = 9 over the 2 frames
- If the player scores a spare, then they are given an extra roll.
- the score is the sum of all 3 rolls.
- If the player scores a strike, then they are given an extra 2 rolls.
- the score is the sum of all 3 rolls.
- Please develop this program in Java - you're more than welcome to use Java 8
- to help, the interface should look like:
scoringGame.roll(numberOfPins); scoringGame.score();
- Do not use an external libraries or frameworks to create the program (unless it is used for testing e.g. JUnit or Mockito)
- No GUIs - a command line program is sufficient.
Please upload on dropbox a zip file containing the solution. This will include the source code (including any test code) and a pre-packaged jar file that can be executed.
The upload link: https://www.dropbox.com/request/GJvHRjT58enYjfqvetGZ