static void BuilderDemo() { AbstractMoutainBike moutainBike = new DownHill(new WideWheel(24), BikeColor.Red); BikeBuilder builder = new MountainBikeBuilder(moutainBike); BikeDirector director = new MountainBikeDirector(); IBicycle bicycle = director.Build(builder); Console.WriteLine(bicycle); }
private static void BuilderPatternDemo() { AbstractMountainBike mountainBike = new Downhill(BikeColor.Gold, new WideWheel(32)); BikeBuilder builder = new MountainBikeBuilder(mountainBike); BikeDirector director = new MountainBikeDirector(); IBicycle bicycle = director.Build(builder); Console.WriteLine(bicycle); }
//Builder Design Pattern Demo Method private static void BuilderPatternDemo() { /*Object instance of AbstractMountainBike created using its child class Downhill. * Its constructor takes 2 arguments*/ AbstractMountainBike mountainBike = new Downhill(BikeColor.Green, new WideWheel(24)); /*Both BikeBuilder and BikeDirector object instances are created. * Build passes the object above into its constructor*/ BikeBuilder builder = new MountainBikeBuilder(mountainBike); BikeDirector director = new MountainBikeDirector(); /*Interface object of IBicycle is assigned the value of the Build method called from the * BikeDirector object above. Its output is displayed on the console*/ IBicycle bicycle = director.Build(builder); Console.WriteLine(bicycle); }