Day 2 Homework #2

wants to merge 2 commits into


None yet

2 participants


So i know i didn't do this like the others. I had planned on doing the extra credit tonight so I started refactoring it in ways it would be easer to add the planned features later. I added a private fight! method that will run all 13 rounds and add the winner to an array. To decide who won the match i search the array for the number of times that fighters name is in the winner array.

I look forward to seeing how some of the other, more proficient developers solve this problem.

@jwo jwo commented on an outdated diff May 3, 2012
+ def fight!
+ round_num = 1
+ do |turn|
jwo May 3, 2012 Member

You used a #select here ... I think an #each would work better... A select is used to reduce the array down by returning true/false to use again later.

@jwo jwo commented on the diff May 3, 2012
@@ -8,4 +8,15 @@
it "should have a winner" do
[strike_a, strike_b].should include, strike_b).winner
+ it "should declare the higher ranking strike winner" do
+ strike_a.stub(:ranking) {8}
jwo May 3, 2012 Member

Good stuff here!

jwo commented May 3, 2012

I think you have a good start here.... The only thing I'd recommend is rather than "puts" out the result, I'd like to be able to replay them again.... So be able to do (after you've fought)

match.turns.each do |turn|
  puts turn.result

Or something similar

@jwo jwo closed this Aug 7, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment