Sha256: 2eabae13e4a3f6f8de5d7f8c64614c53a3dac2375a01eb381d4cac640bac099f
Contents?: true
Size: 830 Bytes
Versions: 1
Compression:
Stored size: 830 Bytes
Contents
module EtudeOp10No6 class Game def initialize @its_current_frame = 0 @first_throw_in_frame = true @its_scorer = Scorer.new end def score score_for_frame(@its_current_frame) end def add(pins) @its_scorer.add_throw(pins) adjust_current_frame(pins) end def score_for_frame(the_frame) @its_scorer.score_for_frame(the_frame) end private def adjust_current_frame(pins) if last_ball_in_frame(pins) advance_frame else @first_throw_in_frame = false end end def last_ball_in_frame(pins) strike(pins) || !@first_throw_in_frame end def strike(pins) @first_throw_in_frame && pins == 10 end def advance_frame @its_current_frame = [10,@its_current_frame+1].min end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
etude_op10_no6-1.0.0 | lib/etude_op10_no6/game.rb |