Skip to content

Instantly share code, notes, and snippets.

@webcoderph
Created October 31, 2018 01:11
Show Gist options
  • Save webcoderph/2ee5a9543060eb6a3d36266346deb319 to your computer and use it in GitHub Desktop.
Save webcoderph/2ee5a9543060eb6a3d36266346deb319 to your computer and use it in GitHub Desktop.
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