示例#1
0
        public static void Main()
        {
            var warehouseManager = new WarehouseManager();
            var stores           = new[]
            {
                new Store(warehouseManager, new WorkingHours(0830, 1900), new[]
                {
                    new ProductRecord("Sofa", 20, 1000),
                    new ProductRecord("HD TV", 1000, 500)
                })
            };

            foreach (var store in stores)
            {
                warehouseManager.Stores.Add(store);
            }

            var sofa = new Product("Sofa");
            var r    = stores[0].GetProductRecord(sofa);

            Console.WriteLine(r);

            try
            {
                stores[0].Buy(sofa);
            }
            catch (ClosedStoreException ex)
            {
            }

            Console.WriteLine(r);
        }
示例#2
0
 /// <summary>
 /// Creates a new store
 /// </summary>
 /// <param name="manager">manager of the chain of stores, that this store is part of</param>
 /// <param name="workingHours">represents opening and closing hours</param>
 /// <param name="records">current inventory of products</param>
 public Store(WarehouseManager manager, WorkingHours workingHours, IEnumerable <ProductRecord> records)
 {
     _manager      = manager;
     _workingHours = workingHours;
     _records      = records.ToList();
 }