95-733 Internet Technologies
Simple Inheritance
class
Mammal
def breathe
puts
"inhale and exhale"
end
end
class
Cat<Mammal
def speak
puts "Meow"
end
end
class
Dog<Mammal
def speak
puts "Woof"
end
end
peanut = Dog.new
sam = Cat.new
peanut.speak
sam.speak
sam.breathe
Output
======
Woof
Meow
inhale and
exhale