예제 #1
0
 public void Assemble()
 {
     _sandwichBuilder.AddBread();
     _sandwichBuilder.AddCheese();
     _sandwichBuilder.AddVeggies();
     _sandwichBuilder.AddCondiments();
     _sandwichBuilder.AddProtein();
 }
예제 #2
0
        public void Run()
        {
            Console.WriteLine("Creating sandwich builder...");
            var builder = new SandwichBuilder();

            Console.WriteLine("Done.");

            Console.WriteLine();

            Console.WriteLine("Creating sandwich 1...");
            var sandwich1 =
                builder
                .AddBread("Rye")
                .AddMeat("Chicken")
                .AddMeat("Turkey")
                .AddSauce("Mayo")
                .GetSandwich();

            Console.WriteLine("Done.");

            DisplaySandwich(sandwich1);

            Console.WriteLine();

            Console.WriteLine("Creating sandwich 2...");
            var sandwich2 =
                builder
                .Reset()
                .AddCondiment("Tomato")
                .AddMeat("Salami")
                .AddCondiment("Lettuce")
                .AddBread("Sourdough")
                .AddCondiment("Onion")
                .GetSandwich();

            Console.WriteLine("Done.");

            DisplaySandwich(sandwich2);
        }