static void Main(string[] args) { CakeBase cakeBase = new CakeBase(); PrintProductDetails(cakeBase); CreamDecorator creamCake = new CreamDecorator(cakeBase); PrintProductDetails(creamCake); CherryDecorator cherryCake = new CherryDecorator(creamCake); PrintProductDetails(cherryCake); ArtificialScentDecorator scentedCake = new ArtificialScentDecorator(cherryCake); PrintProductDetails(scentedCake); NameCardDecorator nameCardCake = new NameCardDecorator(scentedCake); PrintProductDetails(nameCardCake); PastryBase pastryBase = new PastryBase(); PrintProductDetails(pastryBase); CreamDecorator creamPastry = new CreamDecorator(pastryBase); CherryDecorator cherryPastry = new CherryDecorator(creamPastry); PrintProductDetails(cherryPastry); Console.ReadKey(); }
public CakeMaker() { currentCake = null; ingredients = new List <CakeBase>(); ingredients.Add(new ChocolateCake("Chocolate Cake")); ingredients.Add(new FruitCake("Fruit Cake")); ingredients.Add(new ChocoCream("Choco Cream", null)); ingredients.Add(new WhippedCream("Whipped Cream", null)); ingredients.Add(new Strawberry("Strawberry", null)); ingredients.Add(new ForestFruits("Forest Fruits", null)); }
public void SetCakeType(string Name) { CakeBase cb = getCakeBaseByName(Name); if (currentCake == null) { if (!(cb is ToppingBase)) { currentCake = cb.Copy(); } } }
public void AddToppingBase(string Name) { Console.WriteLine(Name); CakeBase cb = getCakeBaseByName(Name); if (cb != null) { if (currentCake != null) { if (cb is ToppingBase) { CakeBase cbCopy = cb.Copy(); ((ToppingBase)cbCopy).NextBase = currentCake.Copy(); currentCake = cbCopy; } } } }
public static void Execute() { // Let us create a Simple Cake Base first CakeBase cBase = new CakeBase(); PrintProductDetails(cBase); // Lets add cream to the cake CreamDecorator creamCake = new CreamDecorator(cBase); PrintProductDetails(creamCake); // Let now add a Cherry on it CherryDecorator cherryCake = new CherryDecorator(creamCake); PrintProductDetails(cherryCake); // Lets now add Scent to it ArtificialScentDecorator scentedCake = new ArtificialScentDecorator(cherryCake); PrintProductDetails(scentedCake); // Finally add a Name card on the cake NameCardDecorator nameCardOnCake = new NameCardDecorator(scentedCake); PrintProductDetails(nameCardOnCake); // Lets now create a simple Pastry PastryBase pastry = new PastryBase(); PrintProductDetails(pastry); // Lets just add cream and cherry only on the pastry CreamDecorator creamPastry = new CreamDecorator(pastry); CherryDecorator cherryPastry = new CherryDecorator(creamPastry); PrintProductDetails(cherryPastry); }
public Fruit(string name, CakeBase Next) : base(name, Next) { }
public Strawberry(string name, CakeBase Next) : base(name, Next) { }
public void RemoveCake() { currentCake = null; }
public Cream(string name, CakeBase Next) : base(name, Next) { }
public ForestFruits(string name, CakeBase Next) : base(name, Next) { }
public WhippedCream(string name, CakeBase Next) : base(name, Next) { }
public ToppingBase(string name, CakeBase Next) : base(name) { NextBase = Next; }