private static void DecoratorPizza() { IPizza orderedPizza = new Pizza("Dominos Margaretta Large (VEG)"); orderedPizza = new ExtraSoya(orderedPizza); orderedPizza = new ExtraCheese(orderedPizza); Console.WriteLine(orderedPizza.Description()); Console.WriteLine("Total Cost = " + orderedPizza.Cost); }
private static void Main(string[] args) { Console.WriteLine("**** Wood Duck ****"); var woodDuck = new WoodDuck(); woodDuck.ShowInfo(); Console.WriteLine("**** Jet Pack Duck ****"); var robotDuck = new JetPackDuck(); robotDuck.ShowInfo(); Console.WriteLine("**** Default Duck ****"); var defaultDuck = new DefaultDuck(); defaultDuck.ShowInfo(); Console.WriteLine("**** Turkey Before adapter ****"); var turkey = new DefaultTurkey(); turkey.ShowInfo(); turkey.MakeGobble(); Console.WriteLine("**** Turkey After adapter ****"); var turkeyAdapted = new TurkeyAdapter(turkey); turkeyAdapted.ShowInfo(); turkeyAdapted.MakeQuack(); var demonDuckmenu = new DemonDucksMenu(); var hollyDucksMenu = new HollyDucksMenu(); var waitress = new Waitress(demonDuckmenu, hollyDucksMenu); waitress.PrintMenu(); MeatBase grillDuck = new GrillDuck(); grillDuck = new ExtraCheese(grillDuck); grillDuck = new GrillVegetables(grillDuck); Console.WriteLine($"Name:{grillDuck.Name}\n Count:{grillDuck.Price()}"); MeatBase grillTurkey = new GrillTurkey(); grillTurkey = new ExtraCheese(grillTurkey); Console.WriteLine($"Name:{grillTurkey.Name}\n Count:{grillTurkey.Price()}"); Console.WriteLine("**** DUCK FABRIC ****"); var single = Singleton.getInstance(); //Pack duck: choose duck and ducks count single.PackDuck(woodDuck, 13); single.PackDuck(defaultDuck, 6); single.PackDuck(robotDuck, 46); single.PackDuck(turkeyAdapted, 6); single.PackDuck(woodDuck, 14);// exept test }
/// <summary> /// Map DBTopping => Topping /// Uses enum to determine which topping class to return. /// </summary> /// <param name="entity"></param> /// <returns></returns> public ATopping Map(DBTopping entity) { ATopping topping = null; switch (entity.TOPPING) { case TOPPINGS.BACON: topping = new Bacon(); break; case TOPPINGS.CHICKEN: topping = new Chicken(); break; case TOPPINGS.EXTRACHEESE: topping = new ExtraCheese(); break; case TOPPINGS.GREENPEPPER: topping = new GreenPepper(); break; case TOPPINGS.HAM: topping = new Ham(); break; case TOPPINGS.NOCHEESE: topping = new NoCheese(); break; case TOPPINGS.PINEAPPLE: topping = new Pineapple(); break; case TOPPINGS.REDPEPPER: topping = new RedPepper(); break; case TOPPINGS.SAUSAGE: topping = new Sausage(); break; default: throw new ArgumentException("Topping not recognized. Topping could not be mapped properly"); } topping.ID = entity.ID; return(topping); }
static void Main(string[] args) { ISandwich sandwich = new Chicken(new Sesam()); sandwich = new ExtraCheese(sandwich); sandwich = new SaltAndPepper(sandwich); sandwich = new Grilled(sandwich); if (sandwich.IsHot) { Console.WriteLine("Caution - HOT"); } Console.WriteLine(string.Join(Environment.NewLine, sandwich.Ingredient)); Console.WriteLine($"Price: {sandwich.Price:C}"); Console.ReadLine(); }