Esempio n. 1
0
 public void BeginBuild(ComplexProduct existingComplexProduct = null)
 {
     if (existingComplexProduct == null)
     {
         ComplexProduct = new ComplexProduct();
     }
     else
     {
         ComplexProduct = existingComplexProduct;
     }
 }
Esempio n. 2
0
        public static void TestCase1()
        {
            AbstractComplexProductBuilder  builder  = new ConcreteProductBuilderA("Sunday", 9);
            GoodWeatherAndGoodLuckDirector director = new GoodWeatherAndGoodLuckDirector();

            builder.BeginBuild();
            director.ConstructWithGoodWeatherAndGoodLuck(builder);
            ComplexProduct productWithGoodLuck = builder.EndBuild();

            Console.WriteLine(productWithGoodLuck.ValueDependOnFortune + ":::" + productWithGoodLuck.ValueDependOnWeather);

            builder.BeginBuild();
            director.ConstructWithBadWeatherAndBadLuck(builder);
            ComplexProduct productWithBadLuck = builder.EndBuild();

            Console.WriteLine(productWithBadLuck.ValueDependOnFortune + "---" + productWithBadLuck.ValueDependOnWeather);
        }