public void BeginBuild(ComplexProduct existingComplexProduct = null) { if (existingComplexProduct == null) { ComplexProduct = new ComplexProduct(); } else { ComplexProduct = existingComplexProduct; } }
public static void TestCase2() { 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); }