Skip to content

class Cat
attr_reader :color, :breed
attr_accessor :name
def initialize(color, breed)
@color = color # instance variable
@breed = breed # instance variable
@hungry = true
end
output = ''
animals = ['cat', 'dog', 'bird']
animals.each do |animal|
output += output + animal + ' '
end
puts output # cat cat dog cat cat dog bird
class Cat
attr_reader :color, :breed
attr_accessor :name
def initialize(color, breed)
@color = color
@breed = breed
@hungry = true
end
def feed(food)
puts "Mmmm, " + food + "!"
class Cat
attr_reader :color, :breed
attr_accessor :name
def initialize(color,breed)
@color = color
@breed = breed
@hungry = true
end
@LucieKla
LucieKla / cat.rb
Last active May 7, 2017 13:20
Cat
class Pet
attr_reader :color, :breed
attr_accessor :name
def initialize(color, breed)
@color = color
@breed = breed
@hungry = true
end
@clemoon
clemoon / cat.rb
Last active May 15, 2017 09:40
cat.rb
class Pet
attr_reader :color, :breed
attr_accessor :name
def initialize(color, breed)
@color = color
@breed = breed
@hungry = true
end
@ssaunier
ssaunier / cat.rb
Created October 17, 2014 07:32
cat.rb
class Cat
def initialize(name, color)
@name = name
@color = color
@alive = true
@color_history = [ color ]
end
attr_reader :name, :color, :color_history
@Veelfiets
Veelfiets / Car.rb
Last active August 29, 2015 14:16
Cat.rb
class Cat
attr_reader :color, :breed, :name
attr_accessor :name
def initialize(color, breed)
@color = color
@breed = breed
@hungry = true
end
def feed(food)
puts "Mmmmmm, " + food + "!"
@davidclayman
davidclayman / cat.rb
Last active December 30, 2017 14:36
cat.rb
class Cat
attr_reader :color, :breed
attr_accessor :name
def initialize(color, breed)
@color = color
@breed = breed
@hungry = true
end
@edjli
edjli / cat.rb
Created July 9, 2018 18:26
cat.rb
class Pet
attr_reader :color, :breed
attr_accessor :name
def initialize(color, breed)
@color = color
@breed = breed
@hungry = true
end
def feed(food)