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

35 lines
878 B
D
Raw Normal View History

2022-11-11 12:51:42 +00:00
module decorator.coffee.app;
import decorator.coffee.beverage;
import decorator.coffee.espresso;
import decorator.coffee.darkroast;
import decorator.coffee.houseblend;
import decorator.coffee.decaf;
import decorator.coffee.mocha;
import decorator.coffee.milk;
import decorator.coffee.soy;
import decorator.coffee.whip;
import std.stdio : writeln;
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 = new Soy(beverage3);
beverage3 = new Mocha(beverage3);
beverage3 = new Whip(beverage3);
print(beverage3);
}