Пример #1
0
 public IProduct GetProduct(int productNumber)
 {
     if (productNumber == 1)
     {
         return(ProductA.GetProductAInstance());
     }
     else
     {
         return(ProductB.GetProductAInstance());
     }
 }
Пример #2
0
        public static Ingrediants GetProduct(string choice)
        {
            Ingrediants createdProduct = null;

            if (choice.Equals("1"))
            {
                createdProduct = new ProductA();
            }
            else if (choice.Equals("2"))
            {
                createdProduct = new ProductB();
            }
            return(createdProduct);
        }
Пример #3
0
        public static Ingrediants GetProduct(string choice)
        {
            Ingrediants createdProduct = null;

            if(choice.Equals("1"))
            {
                createdProduct = new ProductA();
            }
            else if(choice.Equals("2"))
            {
                createdProduct = new ProductB();
            }
            return createdProduct;
        }
Пример #4
0
 public IProduct GetProductFactory(int productNumber)
 {
     IProduct product;
     if (productNumber <= 3)
     {
         product = new ProductA();
     }
     else if (productNumber <= 6)
     {
         product = new ProductB();
     }
     else
     {
         product = new DefaultProduct();
     }
     return product;
 }