Commit bb8ff89
Changed files (6)
bin
lib
mathy
bin/mathy.rb
@@ -3,8 +3,8 @@ require 'mathy'
verifier = Mathy::Verification.new
operations = [
- Mathy::Addition.new(verifier),
- Mathy::Subtraction.new(verifier)
+ Mathy::Operations::Addition.new(verifier),
+ Mathy::Operations::Subtraction.new(verifier)
]
console = Mathy::Console.new
lib/mathy/operations/addition.rb
@@ -0,0 +1,20 @@
+module Mathy
+ module Operations
+ class Addition
+ attr_reader :key
+
+ def initialize(verification)
+ @verifier = verification
+ @key = "+"
+ end
+
+ def play_turn(x: rand(10), y: rand(20), correct_answer: x + y)
+ @verifier.check_answer("#{x} + #{y} = ", correct_answer)
+ end
+
+ def matches?(other_key)
+ key == other_key
+ end
+ end
+ end
+end
lib/mathy/operations/subtraction.rb
@@ -0,0 +1,20 @@
+module Mathy
+ module Operations
+ class Subtraction
+ attr_reader :key
+
+ def initialize(verification)
+ @verifier = verification
+ @key = "-"
+ end
+
+ def play_turn(x: rand(10), y: rand(20), correct_answer: x - y)
+ @verifier.check_answer("#{x} - #{y} = ", correct_answer)
+ end
+
+ def matches?(other_key)
+ key == other_key
+ end
+ end
+ end
+end
lib/mathy/addition.rb
@@ -1,18 +0,0 @@
-module Mathy
- class Addition
- attr_reader :key
-
- def initialize(verification)
- @verifier = verification
- @key = "+"
- end
-
- def play_turn(x: rand(10), y: rand(20), correct_answer: x + y)
- @verifier.check_answer("#{x} + #{y} = ", correct_answer)
- end
-
- def matches?(other_key)
- key == other_key
- end
- end
-end
lib/mathy/subtraction.rb
@@ -1,18 +0,0 @@
-module Mathy
- class Subtraction
- attr_reader :key
-
- def initialize(verification)
- @verifier = verification
- @key = "-"
- end
-
- def play_turn(x: rand(10), y: rand(20), correct_answer: x - y)
- @verifier.check_answer("#{x} - #{y} = ", correct_answer)
- end
-
- def matches?(other_key)
- key == other_key
- end
- end
-end
lib/mathy.rb
@@ -1,9 +1,9 @@
require "mathy/version"
require 'mathy/console'
require 'mathy/verification'
-require 'mathy/addition'
-require 'mathy/subtraction'
require 'mathy/game'
+require 'mathy/operations/addition'
+require 'mathy/operations/subtraction'
module Mathy
end