Beispiel #1
0
        public void Purchases()
        {
            FruitsFarmer fruitFarm = new FruitsFarmer();

            basket.Add(fruitFarm.GetFruit("Apple"));
            basket.Add(fruitFarm.GetFruit("Dragon fruit"));

            MilkFarmer milkFarm = new MilkFarmer();

            basket.Add(milkFarm.GetMilkProduct("Сheese"));
            basket.Add(milkFarm.GetMilkProduct("Yogurt"));

            basket.Add(CandyShop.GetCandy("Гулливер"));
        }
Beispiel #2
0
        public Hypermarket BuyProduct(string productName)
        {
            IProduct product = productName switch
            {
                "Apple" => fruitFarm.GetFruit("Apple"),
                "Dragon fruit" => fruitFarm.GetFruit("Dragon fruit"),
                "Сheese" => milkFarm.GetMilkProduct("Сheese"),
                "Yogurt" => milkFarm.GetMilkProduct("Yogurt"),
                "Гулливер" => CandyShop.GetCandy("Гулливер"),
                _ => new NullProduct()
            };

            products.Add(product);

            return(this);
        }