Commit 584714a

mo khan <mo@mokhan.ca>
2014-04-26 19:16:04
instantiate verification in a single location as a default parameter.
1 parent 861d75e
Changed files (4)
lib/mathy/difficulties/grade_two.rb
@@ -6,10 +6,9 @@ module Mathy
       end
 
       def choose_operation(console)
-        verifier = Verification.new
         console.operation?([
-          Operations::Addition.new(verifier, self),
-          Operations::Subtraction.new(verifier, self)
+          Operations::Addition.new(self),
+          Operations::Subtraction.new(self)
         ])
       end
     end
lib/mathy/operations/addition.rb
@@ -1,8 +1,8 @@
 module Mathy
   module Operations
     class Addition < Operation
-      def initialize(verification, difficulty)
-        super(verification, difficulty, "+")
+      def initialize(difficulty)
+        super(difficulty, "+")
       end
 
       def calculate(operands)
lib/mathy/operations/operation.rb
@@ -3,10 +3,10 @@ module Mathy
     class Operation
       attr_reader :key
 
-      def initialize(verification, difficulty, key)
-        @verifier = verification
+      def initialize(difficulty, key, verification = Verification.new)
         @difficulty = difficulty
         @key = key
+        @verifier = verification
       end
 
       def play_turn
lib/mathy/operations/subtraction.rb
@@ -1,8 +1,8 @@
 module Mathy
   module Operations
     class Subtraction < Operation
-      def initialize(verification, difficulty)
-        super(verification, difficulty, "-")
+      def initialize(difficulty)
+        super(difficulty, "-")
       end
 
       def calculate(operands)