public int GetScore() { BuildGame(); var frameIndex = 0; while (frameIndex < Constants.FramesPerGame - 1) { var frames = new List <Frame>(); if (frameIndex == Constants.FramesPerGame - 2)//For 9th frame { frames.Add(Frames[frameIndex]); frames.Add(null); frames.Add(null); } else if (frameIndex == Constants.FramesPerGame - 3)//For 8th frame { frames.Add(Frames[frameIndex]); frames.Add(Frames[frameIndex + 1]); frames.Add(null); } else { frames.Add(Frames[frameIndex]); frames.Add(Frames[frameIndex + 1]); frames.Add(Frames[frameIndex + 2]); } GameScore += frame.GetScore(frames, FinalFrame); frameIndex++; } GameScore += finalFrame.GetScore(FinalFrame); return(GameScore); }
private int CalculateNormalFrame(int frameIndex, IFrame frame) { var totalFrameScore = frame.GetScore(); if (frame.IsStrike()) { totalFrameScore = CalculateStrikeScore(frameIndex, totalFrameScore); } else if (frame.IsSpare()) { totalFrameScore = CalculateSpareScore(frameIndex, totalFrameScore); } return(totalFrameScore); }
private static int CalculateTenthFrame(int frameIndex, IFrame frame) => frame.GetScore();