Exemple #1
0
        public int GameScore()
        {
            Score gameScore = new Score();

            for (int i = 0; i < _frames.Count; i++)
            {
                if (_frames[i].IsStrike())
                {
                    gameScore.AddBallScore(10);
                    gameScore.AddNextTwoBallScores(SecondBallScore(i), ThirdBallScore(i));
                }
                else if (_frames[i].IsSpare())
                {
                    gameScore.AddBallScore(10);
                    gameScore.AddNextBallScore(SecondBallScore(i));
                }
                else
                {
                    gameScore.AddBallScore(_frames[i].GetBallScore(0));

                    if (_frames[i].BallCount() > 1)
                    {
                        gameScore.AddBallScore(_frames[i].GetBallScore(1));
                    }
                }
            }
            return(gameScore.GetFinalScore());
        }