static void Main(string[] args) { PizzaBuilder hawaiianPizzaBuilder = new HawaiianPizzaBuilder(); Cook cook = new Cook(); cook.SetPizzaBuilder(hawaiianPizzaBuilder); cook.ConstructPizza(); // create the product Pizza hawaiian = cook.GetPizza(); PizzaBuilder spicyPizzaBuilder = new SpicyPizzaBuilder(); cook.SetPizzaBuilder(spicyPizzaBuilder); cook.ConstructPizza(); // create another product Pizza spicy = cook.GetPizza(); }
static void Main(string[] args) { PizzaBuilder hawaiianPizzaBuilder = new HawaiianPizzaBuilder(); var cook = new Cook(); cook.SetPizzaBuilder(hawaiianPizzaBuilder); cook.ConstructPizza(); // create the product var hawaiian = cook.GetPizza(); PizzaBuilder spicyPizzaBuilder = new SpicyPizzaBuilder(); cook.SetPizzaBuilder(spicyPizzaBuilder); cook.ConstructPizza(); // create another product var spicy = cook.GetPizza(); }
// Builder - abstract interface for creating objects (the product, in this case) // Director - responsible for managing the correct sequence of object creation. // Receives a Concrete Builder as a parameter and executes the necessary operations on it. public void TestBuilder() { PizzaBuilder hawaiianPizzaBuilder = new HawaiianPizzaBuilder(); var cook = new Cook(); cook.SetPizzaBuilder(hawaiianPizzaBuilder); cook.ConstructPizza(); // create the product Pizza hawaiian = cook.GetPizza(); PizzaBuilder spicyPizzaBuilder = new SpicyPizzaBuilder(); cook.SetPizzaBuilder(spicyPizzaBuilder); cook.ConstructPizza(); // create another product Pizza spicy = cook.GetPizza(); }
static void Main(string[] args) { PizzaBuilder hawaiianpizzabuilder = new HawaiianPizzaBuilder(); Cook cook = new Cook(); cook.SetPizzaBuilder(hawaiianpizzabuilder); cook.ConstructPizza(); Pizza hawaiian = cook.GetPizza(); }