coding for food
[Ruby] class //Inheritance
silveryen
2022. 8. 26. 08:43
class Chef # superclass
def make_chicken
puts "The chef makes chicken"
end
def make_salad
puts "The chef makes salad"
end
def make_special_dish
puts "The chef makes bbq ribs"
end
end
class ItalianChef < Chef # subclass
def make_special_dish
puts "The chef makes eggplant parm"
end
end
chef = Chef.new()
chef.make_special_dish
italian_chef = ItalianChef.new()
italian_chef.make_special_dish