Created
January 14, 2016 10:32
-
-
Save krokrob/7dcd9a0c00136aaf97a0 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| 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