static void Main(string[] args) { /* * Aqui creamos las bebidas para adicionarlas con los decoradores * entra a la clase Espresso para analizarla */ IBeverage beverage = new Espresso(); Console.WriteLine(beverage.Description() + " $ " + beverage.Cost()); IBeverage beverage2 = new DarckRoast(); /* * Aqui agregamos aditamentos a las bebidas * Entra a la clase Mocha para analizar como * es que se agrega la funcionalidad */ beverage2 = new Mocha(beverage2); beverage2 = new Mocha(beverage2); beverage2 = new Whip(beverage2); Console.WriteLine(beverage2.Description() + " $ " + beverage2.Cost()); IBeverage beverage3 = new HouseBlend(); beverage3 = new Soy(beverage3); beverage3 = new Mocha(beverage3); beverage3 = new Whip(beverage3); Console.WriteLine(beverage3.Description() + " $ " + beverage3.Cost()); Console.ReadLine(); }
static void Main(string[] args) { /* * Design principle: Classes should be open for extension, but closed for modification. * * The Decorator Pattern: attaches additional responsabilities to an object dynamically. * Decorators provide a flexible alternative to subclassing for extending functionality. */ Beverage beverage = new Expresso(); Console.WriteLine($"{beverage.GetDescription()} ${beverage.Cost()}"); Beverage beverage2 = new DarkRoast(); beverage2 = new Mocha(beverage2); beverage2 = new Mocha(beverage2); beverage2 = new Whip(beverage2); Console.WriteLine($"{beverage2.GetDescription()} ${beverage2.Cost()}"); Beverage beverage3 = new HouseBlend(); beverage3 = new Soy(beverage3); beverage3 = new Mocha(beverage3); beverage3 = new Whip(beverage3); Console.WriteLine($"{beverage3.GetDescription()} ${beverage3.Cost()}"); Console.ReadKey(); }
private static void Coffee() { Beverage beverage = new Espresso(); Console.WriteLine(beverage.GetDescription() + " $" + beverage.Cost()); beverage = new Venti(beverage); Console.WriteLine(beverage.GetDescription() + " $" + beverage.Cost()); Beverage beverage2 = new HouseBlend(); beverage2 = new Mocha(beverage2); beverage2 = new Soy(beverage2); beverage2 = new Whip(beverage2); Console.WriteLine(beverage2.GetDescription() + " $" + beverage2.Cost()); beverage2 = new Tall(beverage2); Console.WriteLine(beverage2.GetDescription() + " $" + beverage2.Cost()); Beverage beverage3 = new DarkRoast(); beverage3 = new Mocha(beverage3); beverage3 = new Mocha(beverage3); beverage3 = new Whip(beverage3); Console.WriteLine(beverage3.GetDescription() + " $" + beverage3.Cost()); beverage3 = new Grande(beverage3); Console.WriteLine(beverage3.GetDescription() + " $" + beverage3.Cost()); }
static void Main(string[] args) { Beverage beverage = new Espresso(); Console.WriteLine(beverage.GetDescription() + " $" + beverage.Cost()); Beverage beverage2 = new DarkRoast(); beverage2.SetSize(Beverage.Size.VENTI); beverage2 = new Mocha(beverage2); beverage2 = new Mocha(beverage2); beverage2 = new Whip(beverage2); Console.WriteLine(beverage2.GetDescription() + " $" + beverage2.Cost()); Beverage beverage3 = new DarkRoast(); beverage3.SetSize(Beverage.Size.GRANDE); beverage3 = new Soy(beverage3); beverage3 = new Mocha(beverage3); beverage3 = new Whip(beverage3); Console.WriteLine(beverage3.GetDescription() + " $" + beverage3.Cost()); Console.ReadLine(); }
static void Main(string[] args) { Beverage espresso = new Espresso(); Beverage espressoWithMilk = new Milk(espresso); Beverage espressoWithMilkAndWhip = new Whip(espressoWithMilk); Console.WriteLine($"{espressoWithMilk.GetDescription()} : {espressoWithMilk.Cost()}"); Console.WriteLine($"{espressoWithMilkAndWhip.GetDescription()} : {espressoWithMilkAndWhip.Cost()}"); Console.Read(); }
static void Main(string[] args) { var beverage = new Espresso(); Console.WriteLine($"{beverage.Description} $ {beverage.Cost()}"); Beverage beverage2 = new HouseBlend(); beverage2 = new Mocha(beverage2); beverage2 = new Mocha(beverage2); beverage2 = new Whip(beverage2); Console.WriteLine($"{beverage2.Description} $ {beverage2.Cost()}"); Beverage beverage3 = new Espresso(); beverage3 = new Mocha(beverage3); beverage3 = new Whip(beverage3); Console.WriteLine($"{beverage2.Description} $ {beverage2.Cost()}"); }
public void TestOrderDarkRoastWithMochaWhip() { Beverage beverage = new DarkRoast(); beverage = new Mocha(beverage); beverage = new Mocha(beverage); beverage = new Whip(beverage); string test = $"{beverage.GetDescription()} ${beverage.Cost().ToString("0.00")}"; Assert.AreEqual(test, "Dark Roast, Mocha, Mocha, Whip $2.54"); }
public void TestOrderHouseBlendWithSoyMochaWhip() { Beverage beverage = new HouseBlend(); beverage = new Soy(beverage); beverage = new Mocha(beverage); beverage = new Whip(beverage); string test = $"{beverage.GetDescription()} ${beverage.Cost().ToString("0.00")}"; Assert.AreEqual(test, "House Blend Coffee, Soy, Mocha, Whip $1.49"); }
static void Main(string[] args) { Beverage beverage = new Espresso(); Console.WriteLine(beverage.GetDescription() + ", total £" + beverage.Cost()); Beverage beverage2 = new HouseBlend(); Console.WriteLine(beverage2.GetDescription() + ", total £" + beverage2.Cost()); beverage2 = new Mocha(beverage2); beverage2 = new Whip(beverage2); Console.WriteLine(beverage2.GetDescription() + ", total £" + beverage2.Cost()); }
static void Main(string[] args) { Beverage beverage = new Espresso(); beverage = new Venti(beverage); Console.WriteLine(beverage.GetDescription() + " $" + beverage.Cost()); Beverage beverage5 = new Espresso(); beverage5 = new Grande(beverage5); Console.WriteLine(beverage5.GetDescription() + " $" + beverage5.Cost()); Beverage beverage2 = new DarkRoast(); beverage2 = new Grande(beverage2); beverage2 = new Mocha(beverage2); beverage2 = new Mocha(beverage2); beverage2 = new Whip(beverage2); Console.WriteLine(beverage2.GetDescription() + " $" + beverage2.Cost()); Beverage beverage3 = new HouseBlend(); beverage3 = new Venti(beverage3); beverage3 = new Mocha(beverage3); beverage3 = new Mocha(beverage3); beverage3 = new Whip(beverage3); Console.WriteLine(beverage3.GetDescription() + " $" + beverage3.Cost()); Beverage beverage4 = new Decaf(); beverage4 = new Tall(beverage4); beverage4 = new Milk(beverage4); beverage4 = new Soy(beverage4); beverage4 = new Whip(beverage4); Console.WriteLine(beverage4.GetDescription() + " $" + beverage3.Cost()); }
static void Main(string[] args) { Beverage beverage = new Espresso(); Console.WriteLine(beverage.GetDescription() + " $" + beverage.Cost()); Beverage beverage2 = new DarkRoast(); beverage2 = new Mocha(beverage2); beverage2 = new Mocha(beverage2); beverage2 = new Whip(beverage2); Console.WriteLine(beverage2.GetDescription() + " $" + beverage2.Cost()); Console.ReadKey(); }
public static void Main(string[] args) { Beverage beverage = new Espresso(); Console.WriteLine(beverage.GetDescription() + " $ " + beverage.Cost()); Beverage c1 = new DarkRoast(); c1 = new Mocha(c1); c1 = new Mocha(c1); c1 = new Whip(c1); Console.WriteLine(c1.GetDescription() + " $ " + c1.Cost()); Beverage b3 = new HouseBlend(); b3 = new Soy(b3); b3 = new Mocha(b3); b3 = new Whip(b3); Console.WriteLine(b3.GetDescription() + " $ " + b3.Cost()); }
static void Main(string[] args) { Beverage beverage = new Espresso(); Console.WriteLine(beverage.GetDescription() + " $" + beverage.Cost()); Beverage darkRoast = new DarkRoast(); darkRoast = new Mocha(darkRoast); darkRoast = new Mocha(darkRoast); darkRoast = new Whip(darkRoast); Console.WriteLine(darkRoast.GetDescription() + " $" + darkRoast.Cost()); Beverage houseBlend = new HouseBlend(); houseBlend = new Soya(houseBlend); houseBlend = new Mocha(houseBlend); houseBlend = new Whip(houseBlend); Console.WriteLine(houseBlend.GetDescription() + " $" + houseBlend.Cost()); }
static void Main(string[] args) { IBeverage beverage = new Espresso(); Console.WriteLine(beverage.Description + " $" + beverage.Cost()); IBeverage beverage2 = new DarkRoast(); beverage2 = new Mocha(beverage2); beverage2 = new Mocha(beverage2); beverage2 = new Whip(beverage2); Console.WriteLine(beverage2.Description + " $" + beverage2.Cost()); IBeverage beverage3 = new DarkRoast(); beverage3 = new Milk(beverage3); beverage3 = new Mocha(beverage3); beverage3 = new Whip(beverage3); Console.WriteLine(beverage3.Description + " $" + beverage3.Cost()); }
static void Main() { Beverage espresso = new Espresso(); Console.WriteLine($"{espresso.GetDescription()} ${espresso.Cost()}"); Beverage darkRoast = new DarkRoast(); darkRoast = new Mocha(darkRoast); darkRoast = new Mocha(darkRoast); darkRoast = new Whip(darkRoast); Console.WriteLine($"{darkRoast.GetDescription()} ${darkRoast.Cost()}"); Beverage houseBlend = new HouseBlend(); houseBlend = new Soy(houseBlend); houseBlend = new Mocha(houseBlend); houseBlend = new Whip(houseBlend); Console.WriteLine($"{houseBlend.GetDescription()} ${houseBlend.Cost()}"); }
static void Main(string[] args) { Beverage beverage = new Espresso(); Console.WriteLine(beverage.Description + " $" + beverage.Cost()); Beverage beverage1 = new DarkRoast(); beverage1 = new Mocha(beverage1); beverage1 = new Mocha(beverage1); beverage1 = new Whip(beverage1); Console.WriteLine(beverage1.Description + " $" + beverage1.Cost()); Beverage beverage2 = new HouseBlend(); beverage2 = new Soy(beverage2); beverage2 = new Mocha(beverage2); beverage2 = new Whip(beverage2); Console.WriteLine(beverage2.Description + " $" + beverage2.Cost()); }
static void Main(string[] args) { Console.WriteLine("Starbuzz Coffee"); Beverage beverage = new Espresso(); Console.WriteLine($"{beverage.Description} : ${beverage.Cost()}"); Beverage beverage1 = new DarkRoast(); beverage1 = new Mocha(beverage1); beverage1 = new Mocha(beverage1); beverage1 = new Whip(beverage1); Console.WriteLine($"{beverage1.Description} : ${beverage1.Cost()}"); Beverage beverage2 = new HouseBlend(); beverage2 = new Soy(beverage2); beverage2 = new Mocha(beverage2); beverage2 = new Whip(beverage2); Console.WriteLine($"{beverage2.Description} : ${beverage2.Cost()}"); }
static void Main(string[] args) { Beverage beverage = new Espresso(); Console.WriteLine($"{beverage.Description} $ {beverage.Cost()}"); Beverage beverage2 = new DarkRoast(); beverage2 = new Mocha(beverage2); beverage2 = new Mocha(beverage2); beverage2 = new Whip(beverage2); Console.WriteLine($"{beverage2.Description} $ {beverage2.Cost()}"); Beverage beverage3 = new DarkRoast(); beverage3 = new Soy(beverage3); beverage3 = new Mocha(beverage3); beverage3 = new Whip(beverage3); Console.WriteLine($"{beverage3.Description} $ {beverage3.Cost()}"); Console.Read(); }
static void Main(string[] args) { Console.OutputEncoding = Encoding.Default; Beverage beverage = new Espresso(); Console.WriteLine(beverage.Description + " - Price: " + beverage.Cost() + " €"); Beverage beverage2 = new DarkRoast(); beverage2 = new Mocha(beverage2); beverage2 = new Mocha(beverage2); beverage2 = new Whip(beverage2); Console.WriteLine(beverage2.Description + " - Price: " + beverage2.Cost() + " €"); Beverage beverage3 = new HouseBlend(); beverage3 = new Soy(beverage3); beverage3 = new Mocha(beverage3); beverage3 = new Whip(beverage3); Console.WriteLine(beverage3.Description + " - Price: " + beverage3.Cost() + " €"); }