Commit ab4761e
Changed files (3)
bin/mathy
@@ -3,16 +3,9 @@
require 'mathy'
module Mathy
- verifier = Mathy::Verification.new
- operations = [
- Mathy::Operations::Addition.new(verifier),
- Mathy::Operations::Subtraction.new(verifier)
- ]
+ console = Console.new
+ difficulty = Difficulties::GradeTwo.new
- console = Mathy::Console.new
-
- player = Player.new(console.greet)
- game = Mathy::Game.new(player)
- difficulty = Mathy::Difficulties::GradeTwo.new
- game.play(console.how_many_turns?, console.operation?(operations), difficulty)
+ game = Game.new(Player.new(console.greet))
+ game.play(console.how_many_turns?, difficulty.choose_operation(console), difficulty)
end
lib/mathy/difficulties/grade_two.rb
@@ -4,6 +4,14 @@ module Mathy
def next_operands
[rand(20), rand(20)].sort.reverse
end
+
+ def choose_operation(console)
+ verifier = Verification.new
+ console.operation?([
+ Operations::Addition.new(verifier),
+ Operations::Subtraction.new(verifier)
+ ])
+ end
end
end
end
Gemfile.lock
@@ -6,6 +6,7 @@ PATH
GEM
remote: https://rubygems.org/
specs:
+ minitest (4.7.5)
rake (10.1.0)
PLATFORMS
@@ -14,4 +15,5 @@ PLATFORMS
DEPENDENCIES
bundler (~> 1.6)
mathy!
+ minitest
rake