Skip to content

Instantly share code, notes, and snippets.

@krokrob
Created January 14, 2016 10:32
Show Gist options
  • Select an option

  • Save krokrob/7dcd9a0c00136aaf97a0 to your computer and use it in GitHub Desktop.

Select an option

Save krokrob/7dcd9a0c00136aaf97a0 to your computer and use it in GitHub Desktop.
class Restaurant
attr_reader :name
def initialize(name, city)
@name, @city = name, city
end
def to_s
return "Welcome to #{@name}, in #{@city}"
end
end
class FastFood < Restaurant
def initialize(name, city, prep_time)
super(name, city)
@prep_time = prep_time
end
def to_s
puts "*******************"
super
end
end
class Gastronomic < Restaurant
def initialize(name, city, stars)
super(name, city)
@stars = stars
end
def to_s
return "Bienvenue chez #{@name}, à #{@city}"
end
end
mcdo = FastFood.new("Mcdo", "Paris", 5)
puts mcdo.name
bocuse = Gastronomic.new("Bocuse", "Lyon", 3)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment