예제 #1
0
        public BoxTwo WrapProduct(IBaseProductFactory baseProduct)
        {
            BoxTwo     box     = new BoxTwo();
            ProductTwo product = baseProduct.MakeProduct();

            box.Product = product;
            return(box);
        }
예제 #2
0
        static void Main(string[] args)
        {
            WrapFactoryTwo factoryTwo = new WrapFactoryTwo();
            PizzaFactory   pizza      = new PizzaFactory();
            ToyCarFactory  carFactory = new ToyCarFactory();

            BoxTwo box3 = new BoxTwo();
            BoxTwo box2 = new BoxTwo();

            box3 = factoryTwo.WrapProduct(pizza);
            box2 = factoryTwo.WrapProduct(carFactory);

            Console.WriteLine(box3.Product.Name + "   " + box3.Product.Price);
            Console.WriteLine(box2.Product.Name + "   " + box2.Product.Price);
        }