Created
June 27, 2016 15:27
-
-
Save shinobcrc/018cf073f9a3d907cc4828ffcc0b98e2 to your computer and use it in GitHub Desktop.
This file contains 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
module Flight | |
def fly | |
puts "I'm a #{self.class}, I'm flying" | |
end | |
end | |
class Animal | |
attr_reader :num_legs, :warm_blooded | |
def initialize(num_legs, warm_blooded) | |
@num_legs = num_legs | |
@warm_blooded = warm_blooded | |
end | |
end | |
class Mammal < Animal | |
attr_reader :has_hair, :has_vertebrate | |
def initialize(num_legs, warm_blooded, has_hair, has_vertebrate) | |
super(num_legs, warm_blooded) | |
@num_legs = 2 | |
@warm_blooded = true | |
@has_hair = has_hair | |
@has_vertebrate = has_vertebrate | |
end | |
end | |
class Bat < Mammal | |
attr_reader :nocturnal | |
include Flight | |
def initialize(num_legs, warm_blooded, has_hair, has_vertebrate, nocturnal) | |
super(num_legs, warm_blooded, has_hair, has_vertebrate, nocturnal) | |
@nocturnal = nocturnal | |
end | |
end | |
class Primate < Mammal | |
attr_reader :has_thumbs | |
def initialize(num_legs, warm_blooded, has_hair, has_vertebrate, has_thumbs) | |
super(num_legs, warm_blooded, has_hair, has_vertebrate) | |
@has_thumbs = has_thumbs | |
end | |
end | |
class Chimpanzee < Primate | |
attr_reader :highly_intelligent | |
def intialize(num_legs, warm_blooded, has_hair, has_vertebrate, has_thumbs, highly_intelligent) | |
super(num_legs, warm_blooded, has_hair, has_vertebrate, has_thumbs) | |
@highly_intelligent = highly_intelligent | |
end | |
end | |
class Amphibian < Animal | |
attr_reader :permeable_skin | |
def initialize(num_legs, warm_blooded, permeable_skin) | |
super(num_legs, warm_blooded) | |
@permeable_skin = permeable_skin | |
end | |
end | |
class Frog < Amphibian | |
attr_reader :long_legs | |
def intialize(num_legs, warm_blooded, permeable_skin, long_legs) | |
super(num_legs, warm_blooded, permeable_skin, long_legs) | |
@num_legs = 4 | |
@long_legs = long_legs | |
end | |
end | |
class Bird < Animal | |
attr_reader :has_wings | |
include Flight | |
def initialize(num_legs, warm_blooded, has_wings) | |
super(num_legs, warm_blooded) | |
@has_wings = has_wings | |
end | |
end | |
class Parrot < Bird | |
attr_reader :can_repeat_words | |
include Flight | |
def initialize(num_legs, warm_blooded, has_wings, can_repeat_words) | |
super(num_legs, warm_blooded, has_wings) | |
@can_repeat_words = can_repeat_words | |
end | |
end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment