Created
April 5, 2013 22:41
-
-
Save udit99/5323268 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 Chicken | |
end | |
class Beef | |
end | |
class Restaurant | |
def initialize meat | |
@meat = meat | |
end | |
def make_sandwich | |
Sandwich.new(@meat).make | |
end | |
def make_stew | |
Stew.new(@meat).make | |
end | |
def make_casserole | |
Casserole.new(@meat).make | |
end | |
end | |
class Sandwich | |
def initialize(meat) | |
@meat = meat | |
end | |
def make | |
puts "#{@meat.class} Sandwich" | |
end | |
end | |
class Stew | |
def initialize(meat) | |
@meat = meat | |
end | |
def make | |
puts "#{@meat.class} Stew" | |
end | |
end | |
class Casserole | |
def initialize(meat) | |
@meat = meat | |
end | |
def make | |
puts "#{@meat.class} Casserole" | |
end | |
end | |
smokies = Restaurant.new(Chicken.new) | |
smokies.make_sandwich | |
smokies.make_stew | |
smokies.make_casserole | |
smokies = Restaurant.new(Beef.new) | |
smokies.make_sandwich | |
smokies.make_stew | |
smokies.make_casserole |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment