Skip to content

Instantly share code, notes, and snippets.

@nafidurmus
Last active July 26, 2019 11:16
Show Gist options
  • Save nafidurmus/1d8b555c97a55614336c465729ca68db to your computer and use it in GitHub Desktop.
Save nafidurmus/1d8b555c97a55614336c465729ca68db to your computer and use it in GitHub Desktop.
class RestaurantServer
def initialize(meal_factory)
@meal_factory = meal_factory
end
def serve!
@meal_factory.new_utensil
@meal_factory.new_dish
end
end
class SushiMealFactory
def new_dish
MaguroSashimi.new
end
def new_utensil
Chopsticks.new
end
end
class SteakMealFactory
def new_dish
FiletMignon.new
end
def new_utensil
Knife.new
end
end
#kullanımı
meal_factory = SushiMealFactory.new
restaurant_server = RestaurantServer.new(meal_factory)
restaurant_server.serve!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment