Created
October 31, 2018 01:11
-
-
Save webcoderph/2ee5a9543060eb6a3d36266346deb319 to your computer and use it in GitHub Desktop.
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 Sugar | |
def initialize(ingredients) | |
@ingredient = ingredients | |
end | |
def cost | |
@ingredient.cost + 1 | |
end | |
end | |
class Milk | |
def initialize(ingredients) | |
@ingredient = ingredients | |
end | |
def cost | |
@ingredient.cost + 2 | |
end | |
end | |
class Chocolate | |
def initialize(ingredients) | |
@ingredient = ingredients | |
end | |
def cost | |
@ingredient.cost + 3 | |
end | |
end | |
class MilkChokoweit | |
def cost | |
0 | |
end | |
end | |
puts "Order Milk Chokoweit" | |
milk_chokoweit = MilkChokoweit.new | |
p Sugar.new(Milk.new(Chocolate.new(milk_chokoweit))).cost |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment