patterns/decorator/coffeewithsize/soy.d

38 lines
708 B
D

module decorator.coffeewithsize.soy;
import decorator.coffeewithsize.beverage;
import decorator.coffeewithsize.condimentdecorator;
class Soy : CondimerDecorator
{
private:
Beverage beverage;
public:
this(Beverage beverage)
{
this.beverage = beverage;
}
override string getDescription()
{
return beverage.getDescription() ~ ", Soy";
}
override double cost()
{
double cost = beverage.cost();
if (beverage.getSize() == Size.TALL)
{
cost += .10;
}
else if (beverage.getSize() == Size.GRANDE)
{
cost += .15;
}
else if (beverage.getSize() == Size.VENTI)
{
cost += .20;
}
return cost;
}
}