From: Robert Klemme Date: 2011-10-05T14:50:01+09:00 Subject: Re: question about method On Wed, Oct 5, 2011 at 7:46 AM, Joseph S. wrote: > class D20 >   def roll_d20 >      1 + rand(20) >   end > end > > class Attack >   def roll >      to_hit = $d20.roll_d20 >      hit_or_miss = to_hit > AC ? "Hit!" : "Miss!" >      puts "Attack roll is #{to_hit} vs. AC #{AC}. " + hit_or_miss >   end > end > > AC = 10 > > $d20 = D20.new > > attack1 = Attack.new > > puts attack1.roll > > FIXED IT! i may be a beginner but i figured it out. should have been > using classes from the start, silly me. It's not the class that made the difference but the variable "to_hit". In your original code this would have been def attack_roll r = roll_d20 if r > AC print "Attack roll is #{r} vs. AC #{AC}. Hit!" else roll_d20 <= AC print "Attack roll is #{r} vs. AC #{AC}. Miss!" end end Kind regards robert -- remember.guy do |as, often| as.you_can - without end http://blog.rubybestpractices.com/