Пример #1
0
        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);
        }
Пример #2
0
        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);
        }
Пример #3
0
 private static int CalculateTenthFrame(int frameIndex, IFrame frame) => frame.GetScore();