This repository has been archived on 2022-11-20. You can view files and clone it, but cannot push or open issues or pull requests.
patterns/decorator/coffeewithsize/soy.d

38 lines
708 B
D
Raw Permalink Normal View History

2022-11-11 12:51:42 +00:00
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;
}
}