Mid From PDF GoF Patterns Gang of Four Patterns

Concrete Builder (MargheritaPizzaBuilder):?

  • The MargheritaPizzaBuilder is a concrete implementation of the

IPizzaBuilder interface. It builds a specific type of pizza (Margherita in

this case) by setting the dough, sauce, and adding toppings. The Build()

method returns the fully constructed pizza.

public class MargheritaPizzaBuilder : IPizzaBuilder
{
private Pizza _pizza = new Pizza();
public void SetDough(string dough) => _pizza.Dough = dough;
public void SetSauce(string sauce) => _pizza.Sauce = sauce;
public void AddTopping(string topping) =>

_pizza.Toppings.Add(topping);

public Pizza Build() => _pizza;
}

More from Design Patterns in C#

All questions for this course
Toolliyo Assistant
Ask about tutorials, ebooks, training, pricing, mentor services, and support. I use public site content only—not admin or internal tools.

care@toolliyo.com

Need callback? Share your details