public int? ScoreFrame(IFrame frameToScore) { if (!frameToScore.IsSpare()) { return null; } var subsequentFrame = frameToScore.NextFrame; var subsequentFrameBall1Pins = subsequentFrame.PinsWithBall1; var frameScore = frameToScore.TotalPins; if (subsequentFrameBall1Pins > 0) { frameScore += subsequentFrameBall1Pins.GetValueOrDefault(0); } return frameScore; }
public IFrameScorer GetScorer(IFrame frameToScore) { IFrameScorer frameScorer; if(frameToScore.IsStrike()) { frameScorer = new StrikeFrameScorer(); } else if(frameToScore.IsSpare()) { frameScorer = new SpareFrameScorer(); } else { frameScorer = new NormalFrameScorer(); } return frameScorer; }
public Score GetBonusScore(IFrame frame) => frame.IsSpare() ? _ball1.TotalScore() : TotalScore();