summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormo khan <mo@mokhan.ca>2014-04-26 20:30:53 -0600
committermo khan <mo@mokhan.ca>2014-04-26 20:30:53 -0600
commitf8c00279727873d8af1e4917a834a0c36a07a266 (patch)
tree0385f3b5abe81d79c39ba945a62bcfb8d04e09d9
parent88f3d899426eaa162e85330d4e4c3487fa25daa9 (diff)
include total time in the final report.
-rw-r--r--lib/mathy/console.rb6
-rw-r--r--lib/mathy/game.rb3
2 files changed, 6 insertions, 3 deletions
diff --git a/lib/mathy/console.rb b/lib/mathy/console.rb
index d286081..fa806c4 100644
--- a/lib/mathy/console.rb
+++ b/lib/mathy/console.rb
@@ -18,10 +18,12 @@ module Mathy
Difficulties::GradeTwo.new
end
- def display_results(player, score, turns_played)
+ def display_results(player, score, turns_played, started_at)
report ""
report "+++++++++++++++++++++++++++++++++++"
- report "You got #{score}/#{turns_played}."
+ report "You got #{score}/#{turns_played} correct."
+ report "Your overall mark is #{(score/turns_played.to_f)*100}%."
+ report "You took #{Time.now - started_at} seconds."
report "Good bye #{player.name}"
report "+++++++++++++++++++++++++++++++++++"
end
diff --git a/lib/mathy/game.rb b/lib/mathy/game.rb
index a9f8b24..9271955 100644
--- a/lib/mathy/game.rb
+++ b/lib/mathy/game.rb
@@ -6,8 +6,9 @@ module Mathy
end
def play(console)
+ started_at = Time.now
turns_played = play_turns(console)
- console.display_results(@player, @score, turns_played)
+ console.display_results(@player, @score, turns_played, started_at)
end
private