patterns/decorator/coffeewithsize/app.d

39 lines
1023 B
D

module decorator.coffeewithsize.app;
import decorator.coffeewithsize.beverage;
import decorator.coffeewithsize.espresso;
import decorator.coffeewithsize.darkroast;
import decorator.coffeewithsize.houseblend;
import decorator.coffeewithsize.decaf;
import decorator.coffeewithsize.mocha;
import decorator.coffeewithsize.milk;
import decorator.coffeewithsize.soy;
import decorator.coffeewithsize.whip;
import std.stdio : writeln;
alias Size = Beverage.Size;
void print(Beverage beverage)
{
writeln(beverage.getDescription(), " $", beverage.cost());
}
void main()
{
Beverage beverage = new Espresso();
print(beverage);
Beverage beverage2 = new DarkRoast();
beverage2 = new Mocha(beverage2);
beverage2 = new Mocha(beverage2);
beverage2 = new Whip(beverage2);
print(beverage2);
Beverage beverage3 = new HouseBlend();
beverage3.setSize(Size.VENTI);
beverage3 = new Soy(beverage3);
beverage3 = new Mocha(beverage3);
beverage3 = new Whip(beverage3);
print(beverage3);
}