Exemplo n.º 1
0
        private static BowlScore CalculateStrike(BowlScore totalScore, Frames frames, int i)
        {
            if (frames[i].IsStrike() && i < frames.Count() - 1)
            {
                totalScore = CalculateStrikeBonusIfNotPenultimateFrame(totalScore, frames, i);
                totalScore = totalScore.Add(frames[i + 1].StrikeBonus());
            }

            return(totalScore);
        }
Exemplo n.º 2
0
        public BowlScore GetIntermediateScore()
        {
            BowlScore totalScore = new BowlScore(0);

            foreach (BowlScore bowl in bowls)
            {
                totalScore = totalScore.Add(bowl);
            }

            return(totalScore);
        }
Exemplo n.º 3
0
        public int FinalScore()
        {
            BowlScore totalScore = new BowlScore(0);

            Frames frames = bowls.GetFrames();

            for (int i = 0; i < frames.Count(); i++)
            {
                totalScore = CalculateSpare(totalScore, frames, i);
                totalScore = CalculateStrike(totalScore, frames, i);

                totalScore = totalScore.Add(frames[i].GetIntermediateScore());
            }

            return(totalScore.ToInt());
        }
Exemplo n.º 4
0
 public BowlScore AddSpareBonus(BowlScore currentScore)
 {
     return(currentScore.Add(bowls[0]));
 }