Created
January 14, 2016 10:32
-
-
Save krokrob/56bd921b41d6b04c6d3c to your computer and use it in GitHub Desktop.
This file contains 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 Chief | |
attr_reader :name, :restaurant | |
def initialize(name, age, restaurant) | |
@name = name | |
@age = age | |
@restaurant = restaurant | |
end | |
end | |
class Restaurant | |
attr_reader :name, :chief | |
def initialize(name, city, chief_name, chief_age) | |
@name, @city = name, city | |
@chief = Chief.new(chief_name, chief_age, self) | |
end | |
def to_s | |
return "Welcome to #{@name}, in #{@city}" | |
end | |
end | |
mama = Restaurant.new("Mama Roma", "Paris", "Georges", 51) | |
georges = mama.chief | |
puts georges.restaurant | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment