Last active
July 15, 2017 22:59
-
-
Save Sihui/30834d210d4881a27f0a60eb581530f0 to your computer and use it in GitHub Desktop.
Design Pattern: Simple Factory and Cheesecake Factory
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
def make_cheesecake(type) | |
cheesecake = nil | |
case type | |
when 'oreo' | |
cheesecake = OreoCheesecake.new | |
when 'coffee' | |
cheesecake = CoffeeCheesecake.new | |
when 'tiramisu' | |
cheesecake = TiramisuCheesecake.new | |
when 'smores' | |
cheesecake = SmoresCheesecake.new | |
when 'hazelnut' | |
cheesecake = HazelnutCheesecake.new | |
else | |
cheesecake = OriginalCheesecake.new | |
end | |
cheesecake.make_crust | |
cheesecake.add_layers | |
cheesecake.bake | |
cheesecake.refrigerate | |
cheesecake.add_toppings | |
cheesecake | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment