Last active
July 14, 2017 15:17
-
-
Save Sihui/4f18589e851b69a50dbadbda7ca2c306 to your computer and use it in GitHub Desktop.
Design Pattern: Template Method and Chipotle
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 GoToOrderSihui | |
def vessel | |
Bowl | |
end | |
def meat | |
Steak | |
end | |
def toppings | |
Tomato + Corn | |
end | |
def extras | |
Guacamole | |
end | |
def order | |
meal = vessel | |
meal << meat | |
meal << toppings | |
meal << extras | |
meal | |
end | |
end | |
class GoToOrderAmber | |
def vessel | |
Burrito | |
end | |
def meat | |
Chicken | |
end | |
def toppings | |
Green Chili + Red Chili | |
end | |
def extras | |
Chips + Soda | |
end | |
def order | |
meal = vessel | |
meal << meat | |
meal << toppings | |
meal << extras | |
meal | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment