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/app.d

39 lines
1023 B
D
Raw Permalink Normal View History

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