scoreForFrame method

int scoreForFrame(
  1. int theFrame
)

Implementation

int scoreForFrame(int theFrame) {
  _ball = 0;
  var score = 0;

  for (var currentFrame = 0; currentFrame < theFrame; currentFrame++) {
    if (_strike) {
      score += 10 + _nextTwoBallsForStrike;
      _ball++;
    } else if (_spare) {
      score += 10 + _nextBallForSpare;
      _ball += 2;
    } else {
      score += _twoBallsInFrame;
      _ball += 2;
    }
  }
  return score;
}