Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            Inventory inventory = new Inventory();

            inventory.Attach(new InventoryCount(inventory));
            inventory.Attach(new InventoryDisplay(inventory));

            Console.WriteLine("=Adding A=");
            inventory.AddProduct(new Product("A"));

            Console.WriteLine("=Adding P=");
            Product p = new Product("P");

            inventory.AddProduct(p);

            Console.WriteLine("=Adding Z=");
            inventory.AddProduct(new Product("Z"));

            Console.WriteLine("=Removing P=");
            inventory.RemoveProduct(p);

            ArrayList ps = new ArrayList();

            ps.Add(new Product("L1"));
            ps.Add(new Product("L2"));
            ps.Add(new Product("L3"));

            Console.WriteLine("=Adding L1, L2, L3=");
            inventory.AddProducts(ps);

            Console.WriteLine("=Removing L1, L2, L3=");
            inventory.RemoveProducts(ps);
        }
Ejemplo n.º 2
0
        public void AddProducts(IEnumerable ps)
        {
            Inventory inv = (Inventory)(object)this;

            foreach (Product p in ps)
            {
                inv.AddProduct(p);
            }
        }