Esempio n. 1
0
        static void Main(string[] args)
        {
            // dependency injection
            var warehouse = new FoodWarehouse(new BaseWarehouse());

            warehouse.AddProduct(new Food("ADGDGDAREQ", "Abc", 53));
            warehouse.AddProduct(new Food("AAA", "AAA", 40));
            warehouse.PrintProducts();

            // adapter
            Shop       store        = new Shop();
            IWarehouse storeAdapter = new ShopAdapter(store);

            storeAdapter.AddProduct(new Food("FADF", "EEE", 3441));
            storeAdapter.PrintProducts();

            // iterator
            foreach (var element in warehouse)
            {
                Console.WriteLine(element);
            }
        }
Esempio n. 2
0
 public FoodIterator(FoodWarehouse warehouse)
 {
     this.collection = warehouse;
     this.position   = -1;
 }