Sha256: a2f0625b07b97d6509d4e555c9a7e567cf8c9951adbbcbac9c580d5313e768c8
Contents?: true
Size: 452 Bytes
Versions: 1
Compression:
Stored size: 452 Bytes
Contents
module Kakunin class Math def initialize(min: 10, max: 99, input: STDIN, output: STDOUT) @min = min @max = max @input = input @output = output end def value Random.rand(@min..@max) end def ask x = value y = value @output << "#{x} + #{y} = " result = Integer(@input.gets.strip) (x + y == result) || (raise "wrong answer, #{x} + #{y} != #{result}") end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
kakunin-0.1.0 | lib/kakunin/math.rb |