java测试案例,基于测试的java开发案例

41528d3028836879cd698677c3999917.gif基于测试的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 {}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值