Mid From PDF GoF Patterns Gang of Four Patterns

Product (Pizza):?

  • The Pizza class is the Product that we are constructing. It has properties for

Dough, Sauce, and a list of Toppings. The ToString() method is

overridden to provide a string representation of the pizza.

public class Pizza
{
public string Dough { get; set; }
public string Sauce { get; set; }
public List<string> Toppings { get; } = new List<string>();
public override string ToString() =>

$"Pizza with {Dough} dough, {Sauce} sauce and toppings:

{string.Join(", ", Toppings)}";

}

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