Skip to content

Instantly share code, notes, and snippets.

Created June 20, 2016 13:36
Show Gist options
  • Save anonymous/b71b70034bfde2a5929d5d40a52d371b to your computer and use it in GitHub Desktop.
Save anonymous/b71b70034bfde2a5929d5d40a52d371b to your computer and use it in GitHub Desktop.
class Animal
attr_accessor :name
attr_accessor :age
attr_accessor :sex
@animals = []
def initialize(name, sex, age)
@name = name
@sex = sex
@age = age
@hunger_level = rand(10)
"THE SAME ANIMAL - ERROR!" if @animals.include?(@name)
end
p @animals
end
class Lion < Animal
#hunger_level = rand(10)
end
class Tiger < Animal
#hunger_level = rand(10)
end
class Monkey < Animal
#hunger_level = rand(10)
end
class Zoo
@animals_in_zoo = []
def add_animal(name)
if @animals_in_zoo.include?(name)
"THE SAME ANIMAL - ERROR!"
else
@animals_in_zoo.push(@name)
end
end
def feed_animal
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment