Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- {
- "exercise":"bowling",
- "version":"0.1.0",
- "comments":[
- "Students should implement roll and score methods.",
- "Roll should accept a single integer.",
- "Score should return the game's final score, when possible",
- "For brevity the tests display all the rolls in an array;",
- "each element of the rolls array should be passed to the roll method",
- "The final tests define situations where the score can not be returned",
- "The expection for these tests is -1, indicating an error",
- "In these cases you should expect an error as is idiomatic for your language",
- "When to error is also left up to your implementation. There are two options",
- " - Error as soon as an invalid roll is made",
- " - Error when scoring a game with an invalid roll",
- "You can also error in both cases."
- ],
- "group":[
- {
- "description":"returns the final score of a bowling game",
- "group":[
- {
- "score":{
- "description":"should be able to score a game with all zeros",
- "rolls":[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
- "expected":0
- }
- },
- {
- "score":{
- "description":"should be able to score a game with no strikes or spares",
- "rolls":[3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6],
- "expected":90
- }
- },
- {
- "score":{
- "description":"a spare followed by zeros is worth ten points",
- "rolls":[6, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
- "expected":10
- }
- },
- {
- "score":{
- "description":"points scored in the roll after a spare are counted twice",
- "rolls":[6, 4, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
- "expected":16
- }
- },
- {
- "score":{
- "description":"consecutive spares each get a one roll bonus",
- "rolls":[5, 5, 3, 7, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
- "expected":31
- }
- },
- {
- "score":{
- "description":"a spare in the last frame gets a one roll bonus that is counted once",
- "rolls":[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 3, 7],
- "expected":17
- }
- },
- {
- "score":{
- "description":"a strike earns ten points in a frame with a single roll",
- "rolls":[10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
- "expected":10
- }
- },
- {
- "score":{
- "description":"points scored in the two rolls after a strike are counted twice as a bonus",
- "rolls":[10, 5, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
- "expected":26
- }
- },
- {
- "score":{
- "description":"consecutive strikes each get the two roll bonus",
- "rolls":[10, 10, 10, 5, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
- "expected":81
- }
- },
- {
- "score":{
- "description":"a strike in the last frame gets a two roll bonus that is counted once",
- "rolls":[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 7, 1],
- "expected":18
- }
- },
- {
- "score":{
- "description":"rolling a spare with the two roll bonus does not get a bonus roll",
- "rolls":[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 7, 3],
- "expected":20
- }
- },
- {
- "score":{
- "description":"strikes with the two roll bonus do not get bonus rolls",
- "rolls":[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 10, 10],
- "expected":30
- }
- },
- {
- "score":{
- "description":"a strike with the one roll bonus after a spare in the last frame does not get a bonus",
- "rolls":[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 3, 10],
- "expected":20
- }
- },
- {
- "score":{
- "description":"all strikes is a perfect game",
- "rolls":[10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10],
- "expected":300
- }
- },
- {
- "score":{
- "description":"rolls can not score negative points",
- "rolls":[-1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
- "expected":-1
- }
- },
- {
- "score":{
- "description":"a roll can not score more than 10 points",
- "rolls":[11, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
- "expected":-1
- }
- },
- {
- "score":{
- "description":"two rolls in a frame can not score more than 10 points",
- "rolls":[5, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
- "expected":-1
- }
- },
- {
- "score":{
- "description":"bonus roll after a strike in the last frame can not score more than 10 points",
- "rolls":[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 11],
- "expected":-1
- }
- },
- {
- "score":{
- "description":"two bonus rolls after a strike in the last frame can not score more than 10 points",
- "rolls":[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 5, 6],
- "expected":-1
- }
- },
- {
- "score":{
- "description":"two bonus rolls after a strike in the last frame can score more than 10 points if one is a strike",
- "rolls":[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 10, 6],
- "expected":26
- }
- },
- {
- "score":{
- "description":"the second bonus rolls after a strike in the last frame can not be a strike if the first one is not a strike",
- "rolls":[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 6, 10],
- "expected":-1
- }
- },
- {
- "score":{
- "description":"second bonus roll after a strike in the last frame can not score than 10 points",
- "rolls":[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 10, 11],
- "expected":-1
- }
- },
- {
- "score":{
- "description":"an unstarted game can not be scored",
- "rolls":[],
- "expected":-1
- }
- },
- {
- "score":{
- "description":"an incomplete game can not be scored",
- "rolls":[0, 0],
- "expected":-1
- }
- },
- {
- "score":{
- "description":"a game with more than ten frames can not be scored",
- "rolls":[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
- "expected":-1
- }
- },
- {
- "score":{
- "description":"bonus rolls for a strike in the last frame must be rolled before score can be calculated",
- "rolls":[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10],
- "expected":-1
- }
- },
- {
- "score":{
- "description":"both bonus rolls for a strike in the last frame must be rolled before score can be calculated",
- "rolls":[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 10],
- "expected":-1
- }
- },
- {
- "score":{
- "description":"bonus roll for a spare in the last frame must be rolled before score can be calculated",
- "rolls":[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 3],
- "expected":-1
- }
- }
- ]
- }
- ]
- }
Add Comment
Please, Sign In to add comment