Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion superfight.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,15 @@
puts "What is your second fighter's name?"
fighter_b = $stdin.gets

match = Match.new(Fighter.new(fighter_a), Fighter.new(fighter_b))
match = Match.new(Fighter.new(fighter_a), Fighter.new(fighter_b)) do
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would be extremely difficult to full off -- you'd need to have a block on initialize ("new").

But, instead, I think you want "tap" here .... think of tap like this:

class Thermometer
  attr_accessor :temp
end


gauge = Thermometer.new.tap{|t| t.temp = 95}

# OR

gauge = Thermometer.new.tap do |t| 
  t.temp = 95
end

gauge.temp
=> 95

tldr: match = Match.new(Fighter.new(fighter_a), Fighter.new(fighter_b)).tap |match| do

13.times.map do
match = Match.new
if @fighter_a.strike == turn.winner
puts "Fighter A -- #{@fighter_a.name} -- won"
else
puts "Fighter B -- #{@fighter_b.name} -- won"
end
end
end

puts "The winner of match is ....... #{match.winner.name}"