Using system;
namespace Pattern {///
Myb.buildparta (); myb.buildpartb (); return myb.getProduct ();
}
} Public class ConcreateBuilder1: builder {private product p = new product (); public ConcreateBuilder1 () {} public void buildPartA () {p.name = "A"; System.Console.WriteLine ( "build1 part name a"); } Public void buildpartb () {p.date = "b"; system.console.writeline ("build1 part b");} public product getProduct () {system.console.writeline ("build1 product"); return P }}
public class ConcreateBuilder2: builder {private product p = new product (); public ConcreateBuilder2 () {} public void buildPartA () {p.name = "A"; System.Console.WriteLine ( "build2 part name a");} Public void buildpartb () {p.date = "b"; system.console.writeline ("build2 part b");} public product getProduct () {system.console.writeline ("build 2 product"); return P ;}}} // Build mode Builder Director D = New Director (New ConcreateBuilder1 ()); D.Construct ();
D = New Director (New ConcreateBuilder2 ()); D.Construct ();