Skip to content

Instantly share code, notes, and snippets.

@JonFranchi
Created June 24, 2015 03:58
Show Gist options
  • Save JonFranchi/f635065f9ca2c5756ec2 to your computer and use it in GitHub Desktop.
Save JonFranchi/f635065f9ca2c5756ec2 to your computer and use it in GitHub Desktop.
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