Пример #1
0
        public static void Main(string[] args)
        {
            // Set Medium size, add Sauce, add Provolone cheese, add Pepperoni, add Olives, then build.
            var pizzaPepOlives = new PizzaBuilder(Size.Medium)
                                 .AddSauce()
                                 .AddCheese(Cheese.Provolone)
                                 .AddPepperoni()
                                 .AddOlives()
                                 .Build();

            var pizzaOlivesMushrooms = new PizzaBuilder()
                                       .AddSauce()
                                       .AddCheese()
                                       .AddOlives()
                                       .AddMushrooms()
                                       .Build();

            Console.WriteLine(pizzaPepOlives);
            Console.WriteLine(pizzaOlivesMushrooms);

            char[] arr = { 'a', 'b', 'c' };

            string res = new StringBuilder()
                         .Append(true)
                         .Append('a')
                         .Append(arr)
                         .Append("string")
                         .Append(100L)
                         .Append(100.23)
                         .Append('x', 4)
                         .ToString();

            Console.WriteLine(res);
        }
Пример #2
0
 public Pizza(PizzaBuilder builder)
 {
     Size      = builder.Size;
     Cheese    = builder.Cheese;
     Sauce     = builder.Sauce;
     Pepperoni = builder.Pepperoni;
     Ham       = builder.Ham;
     Olives    = builder.Olives;
     Mushrooms = builder.Mushrooms;
 }