static void Main(string[] args) { //LargePizza largePizza = new LargePizza(); Pizza largePizza = new LargePizza(); largePizza = new Cheese(largePizza); largePizza = new Ham(largePizza); largePizza = new Peppers(largePizza); //Console.WriteLine(largePizza.Description); Console.WriteLine(largePizza.GetDescription()); Console.WriteLine("{0:C2}", largePizza.CalculateCost()); Console.ReadKey(); Console.WriteLine(); Beverage coffee = new Espresso(); coffee = new Mocha(coffee); coffee = new Mocha(coffee); coffee = new Whip(coffee); Console.WriteLine(coffee.GetDescription()); Console.WriteLine("{0:C2}", coffee.Cost()); Console.ReadKey(); }
public void Allow_Being_Decorated_With_Cheese_And_Ham_And_Peppers() { Pizza largePizza = new LargePizza(); largePizza = new Cheese(largePizza); largePizza = new Ham(largePizza); largePizza = new Peppers(largePizza); Assert.Equal("Large Pizza, Cheese, Ham, Peppers", largePizza.GetDescription()); Assert.Equal(13.25m, largePizza.CalculateCost()); }
private static void Main(string[] args) { Pizza largePizza = new LargePizza(); largePizza = new Cheese(largePizza); largePizza = new Peppers(largePizza); Console.WriteLine(largePizza.GetDescription()); Console.WriteLine(largePizza.CalculateCost().ToString("C")); Console.ReadKey(); }
private static void Main(string[] args) { Hamburger largeHamburger = new BlueStack(); largeHamburger = new Cheese(largeHamburger); largeHamburger = new Ham(largeHamburger); largeHamburger = new Peppers(largeHamburger); Console.WriteLine(largeHamburger.GetDescription()); Console.WriteLine("{0:C2}", largeHamburger.CalculateCost()); Console.ReadKey(); }
private static void Main(string[] args) { Pizza largePizza = new LargePizza(); largePizza = new Cheese(largePizza); largePizza = new Ham(largePizza); largePizza = new Peppers(largePizza); Console.WriteLine(largePizza.GetDescription()); Console.WriteLine("{0:C2}", largePizza.CalculateCost()); Console.ReadLine(); }
private static void Main() { Pizza largePizza = new LargePizza(); largePizza = new Cheese(largePizza); largePizza = new Ham(largePizza); largePizza = new Peppers(largePizza); Console.WriteLine($"Pizza Description: {largePizza.GetDescription()}"); Console.WriteLine($"Pizza Price: {largePizza.GetPrice()}"); Console.ReadKey(); }
public void CreateMediumPizzaWithCheeseHamPeppers() { IPizza sut = new MediumPizza(); sut = new Cheese(sut); sut = new Ham(sut); sut = new Peppers(sut); var expected = new MediumPizza { Description = "Medium Pizza, Cheese, Ham, Peppers" }; Assert.Equal(expected.Description, sut.GetDescription()); }
static void Main() { Pizza largePizza = new LargePizza(); //Adding Cheese to Large Pizza largePizza = new Cheese(largePizza); //Adding Ham to Large Pizza largePizza = new Ham(largePizza); //Adding Peppers to Large largePizza = new Peppers(largePizza); Console.WriteLine(largePizza.GetDescription()); Console.WriteLine("{0:C2}", largePizza.CalculatePrice()); Console.ReadKey(); }
private static void DemoDecoratorPattern() { #region Without DecoratorPattern //LargePizza largePizza = new LargePizza(); //Console.WriteLine(largePizza.Description); //Console.WriteLine("{0:C2}", largePizza.CalculateCost()); #endregion #region With DecoratorPattern Pizza largePizza = new LargePizza(); largePizza = new Cheese(largePizza); largePizza = new Ham(largePizza); largePizza = new Peppers(largePizza); Console.WriteLine(largePizza.GetDescription()); Console.WriteLine("{0:C2}", largePizza.CalculateCost()); #endregion Console.ReadKey(); }