Created
January 31, 2013 16:55
-
-
Save undecided/4684314 to your computer and use it in GitHub Desktop.
I asked Joey to fix my code. She refused, but she did write this for me #soProud
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Kitten | |
def initialize | |
set_colour | |
set_name | |
end | |
def set_colour | |
if rand(0..1) == 1 | |
@colour = 'White' | |
else | |
@colour = 'Black' | |
end | |
end | |
def set_name | |
if @colour == 'Black' | |
@name = 'Sooty' | |
elsif @colour == 'White' | |
@name = 'Princess' | |
end | |
end | |
def meow | |
puts "#{@name} kitten says: Im a happy kitty! Meow!" | |
end | |
def tiger | |
puts "#{@name} kitten says: Rawr, I is a tiny tiger." | |
end | |
def noise | |
if rand(0..1) == 1 | |
meow | |
else | |
tiger | |
end | |
end | |
end | |
Kitten.new.noise |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment