Mid
From PDF
GoF Patterns
Gang of Four Patterns
Director (PizzaDirector):?
- The PizzaDirector class orchestrates the pizza building process. It uses a
builder to construct a specific type of pizza (like Margherita) by calling the
appropriate methods on the builder. It then returns the final product.
Follow:
public class PizzaDirector
private readonly IPizzaBuilder _builder;
public PizzaDirector(IPizzaBuilder builder) => _builder =
builder;
public Pizza ConstructMargheritaPizza()
_builder.SetDough("Thin Crust");
_builder.SetSauce("Tomato");
_builder.AddTopping("Mozzarella");
return _builder.Build();
Share this Q&A
Share preview image: https://www.toolliyo.com/images/toolliyo-logo.png