I get the following error message when running the code below:
undefine method ‘bottles _of_beer’ for #Bottles:0x2be1e1c
(NoMethodError)
To change this template, choose Tools | Templates
and open the template in the editor.
class Bottles
def initialize (bottles_of_beer, bottle_word, one_word)
@bottles_of_beer = bottles_of_beer
@bottle_word = bottle_word
@one_word = one_word
end
my_bottles = Bottles.new(99,‘Bottles’,‘Bottle’)
while my_bottles.bottles_of_beer >= 2
puts "#{my_bottles.bottles_of_beer} #{my_bottles.bottle_word} of
beer on the wall"
puts “#{my_bottles.bottles_of_beer} #{my_bottles.bottle_word} of beer”
puts “Take one down, pass it around”
my_bottles.bottles_of_beer -= 1
if my_bottles.bottles_of_beer == 1
puts “#{my_bottles.bottles_of_beer} bottle of beer on the wall”
else
puts “#{my.bottles.bottles_of_beer} #{my_bottles.bottle_word}of beer
on the wall”
end
if my_bottles.bottles_of_beer == 1
puts “#{my_bottles.bottles_of_beer} #{my_bottles.one_word} of beer on
the wall”
puts “#{my_bottles.bottles_of_beer} #{my_bottles.one_word} of beer”
puts “Take one down, pass it around”
my_bottles.bottles_of_beer -= 1
puts “No more #{my_bottles.bottle_word} of beer on the wall”
end
end
end
Yeah I know this code is horribly formatted. I’m using Vim text editor, and have not yet figured out how to auto format my code.
What am I doing wrong? I still have a very long way to go, and practice alot more.
Thanks
Zayd