Last active
August 29, 2015 14:23
-
-
Save Shmuwol/b3782b03cc3864cbcf9e to your computer and use it in GitHub Desktop.
Class
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 Animal | |
def initialize(animal) | |
@animal = animal | |
end | |
def sound | |
if @animal == "dog" | |
"Woof! Woof!" | |
elsif @animal == "cat" | |
"Meow!" | |
elsif @animal == "fox" | |
"What does the fox say!?" | |
else | |
end | |
end | |
def loves | |
if @animal == "dog" | |
return "Dogs love: Tennis Balls" | |
elsif @animal == "cat" | |
return "Cats love: Catnip" | |
else | |
end | |
end | |
end | |
cat = Animal.new("cat") | |
p cat.sound | |
p cat.loves | |
dog = Animal.new("dog") | |
p dog.sound | |
p dog.loves |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment