基于测试的java开发案例
Bowling Game KataObject Mentor, Inc.fitnesse.orgCopyright 2005 by Object Mentor, IncAll copies must retain this page Scoring Bowling.The game consists of 10 frames as shown above. In each frame the player hastwo opportunities to knock down 10 pins. The score for the frame is the totalnumber of pins knocked down, plus bonuses for strikes and spares.A spare is when the player knocks down all 10 pins in two tries. The bonus forthat frame is the number of pins knocked down by the next roll. So in frame 3above, the score is 10 (the total number knocked down) plus a bonus of 5 (thenumber of pins knocked down on the next roll.)A strike is when the player knocks down all 10 pins on his first try. The bonusfor that frame is the value of the next two balls rolled.In the tenth frame a player who rolls a spare or strike is allowed to roll the extraballs to complete the frame. However no more than three balls can be rolled intenth frame.The Requirements.• Write a class named “Game” that has two s–roll(pins : int) is called each time the player rolls a ball. The argument is the number of pins knocked down.–score() : int is called only at the very end of the game. It returns the total score for that game.A quick design sessionClearly we need the Game class.A quick design sessionA game has 10 frames.A quick design sessionA frame has 1 or two rolls.A quick design sessionThe tenth frame has two or three rolls.It is different from all the other frames.A quick design sessionThe score function mustiterate through all theframes, and calculateall their scores.A quick design sessionThe score for a spare or a strike depends on the frame’s successorBegin.• Create a project named BowlingGame• Create a unit test named BowlingGameTestimport junit.framework.TestCase;public class BowlingGameTest extends TestCase {}