Last active
January 7, 2018 21:19
-
-
Save Sihui/c9f4dce833eb78c59695a21975485acc to your computer and use it in GitHub Desktop.
Design Pattern: Prototype and Pizza
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 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