private void LoadWareHouses()
 {
     this.Warehouses = new Warehouse[NumberOfWarehouse];
     for (int i = 0; i < NumberOfWarehouse; i++)
     {
         Warehouses[i] = new Warehouse { Index = i };
         LoadWareHouse(Warehouses[i]);
     }
 }
        private void LoadWareHouse(Warehouse warehouse)
        {
            var a = ReadLineAsArrayOfInts();
            warehouse.Location = new Coordinate(a[0], a[1]);

            LoadWarehouseProducts(warehouse.Products);
        }
        void SendDrone(Drone drone, Warehouse warehouse, Order order, Product product, int amount)
        {
            drone.Commands.Add(new LoadCommand(warehouse.Index, product.ProductType, amount));
            drone.Commands.Add(new DeliverCommand(order.Index, product.ProductType, amount));

            drone.WillBeFreeAtStep += GetStepsToDoneOrder(drone, warehouse, order);

            drone.FreeLocation = order.Location;
        }
 void LoadItem(Drone drone, Warehouse warehouse, int productType, int quantity)
 {
     drone.Commands.Add(new LoadCommand(warehouse.Index, productType, quantity));
     drone.WillBeFreeAtStep += GetStepsToGo(drone.FreeLocation, warehouse.Location) + 1;
     drone.FreeLocation = warehouse.Location;
     drone.LoadedProducts.Add(new Product { ProductType = productType, Quantity = quantity });
     warehouse.Products[productType].Quantity -= quantity;
 }
 int GetStepsToDoneOrder(Drone drone, Warehouse warehouse, Order order)
 {
     return GetStepsToGo(drone.FreeLocation, warehouse.Location) + drone.LoadedProducts.Count() + 1 +
            GetStepsToGo(warehouse.Location, order.Location) + 1;
 }
        private IEnumerable<Product> GetMatchedItems(Warehouse warehouse, Order order)
        {
            foreach( var warehouseProduct in warehouse.Products.Where(x=> x.Quantity > 0 ) )
            {
                var p = order.Products.FirstOrDefault(x => x.ProductType == warehouseProduct.ProductType);

                if( p != null )
                {
                    yield return new Product
                    {
                        ProductType = p.ProductType,
                        Quantity = Math.Min(p.Quantity, warehouseProduct.Quantity)
                    };
                }
            }
        }