Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
return .20 + self._beverage.cost()
class Soy(CondimentDecorator):
def __init__(self, beverage):
self._beverage = beverage
def get_description(self):
return self._beverage.get_description() + ", Soy"
def cost(self):
return .15 + self._beverage.cost()
class Whip(CondimentDecorator):
def __init__(self, beverage):
self._beverage = beverage
def get_description(self):
return self._beverage.get_description() + ", Whip"
def cost(self):
return .10 + self._beverage.cost()
###############################################################################
# Simulation
###############################################################################
if __name__ == '__main__':
pass
class Milk(CondimentDecorator):
def __init__(self, beverage):
self._beverage = beverage
def get_description(self):
return self._beverage.get_description() + ", Milk"
def cost(self):
return .10 + self._beverage.cost()
class Mocha(CondimentDecorator):
def __init__(self, beverage):
self._beverage = beverage
def get_description(self):
return self._beverage.get_description() + ", Mocha"
def cost(self):
return .20 + self._beverage.cost()
class Soy(CondimentDecorator):
def __init__(self, beverage):
self._beverage = beverage
return 1.05
###############################################################################
# Condiment decorators
###############################################################################
class CondimentDecorator(Beverage):
__metaclass__ = ABCMeta
@abstractmethod
def get_description(self):
pass
class Milk(CondimentDecorator):
def __init__(self, beverage):
self._beverage = beverage
def get_description(self):
return self._beverage.get_description() + ", Milk"
def cost(self):
return .10 + self._beverage.cost()
class Mocha(CondimentDecorator):
def __init__(self, beverage):
self._beverage = beverage
return .10 + self._beverage.cost()
class Mocha(CondimentDecorator):
def __init__(self, beverage):
self._beverage = beverage
def get_description(self):
return self._beverage.get_description() + ", Mocha"
def cost(self):
return .20 + self._beverage.cost()
class Soy(CondimentDecorator):
def __init__(self, beverage):
self._beverage = beverage
def get_description(self):
return self._beverage.get_description() + ", Soy"
def cost(self):
return .15 + self._beverage.cost()
class Whip(CondimentDecorator):
def __init__(self, beverage):
self._beverage = beverage