B
Ben Galyean
Hello all,
Just started my first Ruby prog and hit a snag almost instantly. I
simply wish to have my selected weapon do it's prescribed damage as I
intend (in this case, it's 1-8 damage). Complete noob here so any help
at all would be greatly appreciated. The following is a re-creation of
my problem:
#***********************************
class Sword
attr_accessor
realDam)
def initialize(aRealDam)
@realDam = aRealDam
end
end
Longsword = Sword.new(rand(8)+1)
weapon = Longsword
begin
5.times {p weapon.realDam}
puts
5.times {p (rand(8)+1)}
end
#*************************************
Output looks like this:
#****Current Longsword damage (Picks a number and 'keeps' it).****
6
6
6
6
6
#****Intended output for the longsword here****
6
8
8
4
8
Just started my first Ruby prog and hit a snag almost instantly. I
simply wish to have my selected weapon do it's prescribed damage as I
intend (in this case, it's 1-8 damage). Complete noob here so any help
at all would be greatly appreciated. The following is a re-creation of
my problem:
#***********************************
class Sword
attr_accessor
def initialize(aRealDam)
@realDam = aRealDam
end
end
Longsword = Sword.new(rand(8)+1)
weapon = Longsword
begin
5.times {p weapon.realDam}
puts
5.times {p (rand(8)+1)}
end
#*************************************
Output looks like this:
#****Current Longsword damage (Picks a number and 'keeps' it).****
6
6
6
6
6
#****Intended output for the longsword here****
6
8
8
4
8