Skip to content

Instantly share code, notes, and snippets.

@stupeters187
Created April 4, 2016 18:26
Show Gist options
  • Save stupeters187/e00e11bf7b7dfcf39fb67ac00035b521 to your computer and use it in GitHub Desktop.
Save stupeters187/e00e11bf7b7dfcf39fb67ac00035b521 to your computer and use it in GitHub Desktop.
module Flight
puts "I'm a bird!, I can fly!"
end
class Animal
attr_reader :num_legs, :prey, :habitat
def initialize(num_legs, prey, habitat)
@num_legs = num_legs
@prey = prey
@habitat = habitat
end
end
class Mammal < Animal
def initialize(prey)
super(2, prey, 'air')
end
end
class Amphibian < Animal
def initialize(num_legs, habitat)
super(num_legs, 'animals', habitat)
end
end
class Primate < Animal
def initialize(num_legs)
super(num_legs, 'bananas', 'ground')
end
end
class Bird < Mammal
def initialize(prey)
super(num_legs, 'worms', habitat)
end
end
class Parrot < Mammal
def initialize(prey)
super(num_legs, 'seeds', habitat)
end
end
class Frog < Amphibian
def initialize(num_legs, habitat)
super('4', prey, 'water') #
end
end
class Bat < Amphibian
def initialize(num_legs, habitat)
super('2', prey, 'air')
end
end
class Chimpanzee < Primate
def initialize(num_legs)
super(4)
end
end
p = Chimpanzee.new(4)
puts p
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment