Skip to content

Instantly share code, notes, and snippets.

@Sihui
Last active January 7, 2018 21:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Sihui/c9f4dce833eb78c59695a21975485acc to your computer and use it in GitHub Desktop.
Save Sihui/c9f4dce833eb78c59695a21975485acc to your computer and use it in GitHub Desktop.
Design Pattern: Prototype and Pizza
class PizzaStore
def take_order(pizza_type)
case pizza_type
when 'pepperoni'
pizza = Pizza.new('Pepperoni Pizza', ['pepperoni', 'shredded mozzarella cheese'])
when 'chicken'
pizza = Pizza.new('Chicken Pizza', ['chicken', 'mushroom', 'spinach'])
else
pizza = Pizza.new('Cheese Pizza', ['cheese'])
end
pizza.bake
pizza
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment