Skip to content

Instantly share code, notes, and snippets.

@krokrob
Created April 14, 2016 08:18
Show Gist options
  • Save krokrob/96b2ec038fc7cfa1f7ca9120684e9fe5 to your computer and use it in GitHub Desktop.
Save krokrob/96b2ec038fc7cfa1f7ca9120684e9fe5 to your computer and use it in GitHub Desktop.
class Restaurant
attr_reader :name, :city
def initialize(name, city)
@name, @city = name, city
end
def welcome
return "Welcome to #{@name}"
end
end
class FastFood < Restaurant
attr_reader :prep_time
def initialize(name, city, prep_time)
super(name, city)
@prep_time = prep_time
end
def welcome
return "Welcome to #{@name}, here we are fast!"
end
end
class Gastronomic < Restaurant
attr_reader :stars
def initialize(name, city, stars)
@name, @city = name, city
@stars = stars
end
def welcome
puts "Here we are starred!"
super
end
end
bk = FastFood.new("Burger King", "Paris", 5)
bouitte = Gastronomic.new("La Bouitte", "St-Martin", 3)
#
p bk
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment