Exemple #1
0
        static void Main(string[] args)
        {
            //factory pattern
            //var factory = new Factory();
            //var people = factory.GetPeople(PeopleType.URBAN);

            //Console.WriteLine(people.GetName());

            //factory method pattern
            var productConcreteFactory = new ProductConcreteFactory();

            Console.WriteLine(productConcreteFactory.DoSomething());

            Console.Read();
        }
Exemple #2
0
        static void Main(string[] args)
        {
            ProductAbstractFactory factory = new ProductConcreteFactory();

            IProduct product = factory.SetPhonePrice();

            Console.WriteLine(string.Format("Type: {0}; Description: {1}; Price {2:C2}",
                                            product.GetType().Name,
                                            product.GetName(),
                                            product.GetPrice()));

            product = factory.SetTabletPrice();
            Console.WriteLine(string.Format("Type: {0}; Description: {1}; Price {2:C2}",
                                            product.GetType().Name,
                                            product.GetName(),
                                            product.GetPrice()));

            Console.ReadKey(true);
        }