Created
June 24, 2015 03:58
-
-
Save JonFranchi/f635065f9ca2c5756ec2 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 Cat | |
attr_reader :color, :breed | |
attr_accessor :name | |
def initialize(color, breed, name) | |
@color = color | |
@breed = breed | |
@name = name | |
@hungry = true | |
end | |
def feed(food) | |
puts "Mmmmm, " + food + "!" | |
@hungry = false | |
end | |
def hungry? | |
if @hungry | |
puts "I'm Hungry!" | |
else | |
puts "I'm full!" | |
end | |
@hungry | |
end | |
def speak | |
puts "Meow!" | |
end | |
end | |
kitty = Cat.new("grey", "Persian", "Charles") | |
puts "Is our cat hungry now?" | |
kitty.hungry? | |
puts "let's feed our cat" | |
kitty.feed("tuna") | |
puts "is our cat hungry now?" | |
kitty.hungry? | |
puts "our cat can make noise" | |
kitty.speak |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment