static void Main(string[] args) { var espresso = new Espresso(); Console.WriteLine(espresso.GetDescription() + " - $" + espresso.GetCost()); var espressoWithMilk = new Milk(new Espresso()); Console.WriteLine(espressoWithMilk.GetDescription() + " - $" + espressoWithMilk.GetCost()); Console.ReadKey(); }
static void Main(string[] args) { Title.UpperIndent(Assembly.GetExecutingAssembly()); Beverage beverage1 = new Coffee("Simple coffee", 20, Size.Small); Beverage beverage2 = new Milk("Milk", 4, beverage1); Beverage beverage3 = new Milk("Milk", 4, beverage2); Console.WriteLine(beverage3.GetCost()); Console.WriteLine(beverage3.GetDescription()); Title.BottonIndent(); }
/// <summary> /// Здесь мы используем паттерн Декоратор /// </summary> private static void Main() { Beverage beverage = new Expresso(); beverage = new Mocha(beverage); beverage = new Mocha(beverage); beverage = new Milk(beverage); Console.WriteLine($"Напиток обошелся в {beverage.Cost()} рублей, в напитке {beverage.GetDescription()}"); }