예제 #1
0
        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);
        }
예제 #2
0
        //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);
        }