static void Main(string[] args) { Beverage beverage = new DarkRoast(); beverage = new MilkShot(beverage); beverage = new Mocha(beverage); Console.WriteLine(string.Format("{0}: {1}", beverage.GetDescription(), beverage.GetCost())); }
static void Main() { Beverage houseBlend = new HouseBlend(); houseBlend.BeverageSize = Beverage.Size.Grande; houseBlend = new Soy(houseBlend); houseBlend = new Mocha(houseBlend); houseBlend = new Mocha(houseBlend); WriteLine($"{houseBlend.GetDescription()} : {houseBlend.Cost()}"); }
static void Main(string[] args) { Baverage baverage = new HouseBlend(); Console.WriteLine(baverage.GetDescription() + " " + baverage.cost()); Baverage baverage2 = new Mocha(baverage); Console.WriteLine($"{baverage2.GetDescription()},cost: {baverage2.cost()}"); Console.Read(); }
static void Main(string[] args) { Coffe coffe = new Expresso(); // Recursion is the fact behind. which keeps track of the encapsulated objects. coffe = new Mocha(coffe); // In this line coffe = Mocha at runtime. coffe = new Milk(coffe); // In this line coffe = Milk at runtime. coffe = new Mocha(coffe); // In this line coffe = Mocha at runtime. Console.WriteLine("Ingredients: " + coffe.GetDescription()); Console.WriteLine("Total Cost: " + coffe.Cost()); }
static void Main(string[] args) { var beverage = new Espresso(); Console.WriteLine(beverage.GetDescription() + " $" + beverage.Cost()); Beverage beverage2 = new HouseBlend(); beverage2 = new Mocha(beverage2); Console.WriteLine(beverage2.GetDescription() + " $" + beverage2.Cost()); }
static void Main(string[] args) { Beverage espresso = new Espresso(); System.Console.WriteLine(espresso.GetDescription() + " - " + espresso.Cost()); Beverage espressoMocha = new Mocha(espresso); System.Console.WriteLine(espressoMocha.GetDescription() + " - " + espressoMocha.Cost()); System.Console.ReadLine(); }
static void Main(string[] args) { Beverage beverage = new Espresso(); Console.WriteLine($"{beverage.GetDescription()} ${beverage.Cost()}"); Beverage beverage2 = new HouseBlend(); beverage2 = new Mocha(beverage2); beverage2 = new Mocha(beverage2); Console.WriteLine($"{beverage2.GetDescription()} ${beverage2.Cost()}"); Console.ReadKey(); }
static void Main(string[] args) { Beverage coffee = new Latte(); Console.WriteLine("Current coffee is: {0}, cost is {1}.", coffee.GetDescription(), coffee.Cost()); Beverage latteWithMilk = new Milk(coffee); Beverage latteWithMilkAndMocha = new Mocha(latteWithMilk); Console.WriteLine("Current coffee is: {0}, cost is {1}.", latteWithMilkAndMocha.GetDescription(), latteWithMilkAndMocha.Cost()); Beverage latteWithMilkAndDoubleMocha = new Mocha(latteWithMilkAndMocha); Console.WriteLine("Current coffee is: {0}, cost is {1}.", latteWithMilkAndDoubleMocha.GetDescription(), latteWithMilkAndDoubleMocha.Cost()); }
static void Main(string[] args) { Beverage beverage = new Espresso(); beverage = new Mocha(beverage); Console.WriteLine(beverage.GetDescription() + "$" + beverage.Cost()); Beverage beverage1 = new HouseBlend(); beverage1 = new Mocha(beverage1); //beverage1 = new Mocha(beverage1); //beverage1 = new Soy(beverage1); //beverage1 = new Soy(beverage1); Console.WriteLine(beverage1.GetDescription() + "$" + beverage1.Cost()); }