Sha256: e2869c683a72afd7a32b60c4f198f6ef96989a50103e2470fffda228bf0c72f1

Contents?: true

Size: 621 Bytes

Versions: 1

Compression:

Stored size: 621 Bytes

Contents

module Mathy
  class Game
    def initialize(console, score = 0)
      @name = console.greet
      @score = score
    end

    def play(games_to_play = 2, operation, difficulty)
      games_to_play.times do
        @score += 1 if operation.play_turn(difficulty.next_operands)
      end

      display_results(@name, @score, games_to_play)
    end

    private

    def display_results(name, score, games_to_play)
      puts ""
      puts "+++++++++++++++++++++++++++++++++++"
      puts "You got #{score}/#{games_to_play}."
      puts "Good bye #{name}"
      puts "+++++++++++++++++++++++++++++++++++"
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
mathy-0.0.1 lib/mathy/game.rb