private void LoadOrder(Order order)
 {
     var a = ReadLineAsArrayOfInts();
     order.Location = new Coordinate(a[0], a[1]);
     var numberOfItems = ReadLineAsArrayOfInts().First();
     LoadOrderProducts(order.Products);
 }
 void UnoadItem(Drone drone, Order order, int productType, int quantity)
 {
     drone.Commands.Add(new DeliverCommand(order.Index, productType, quantity));
     drone.WillBeFreeAtStep += GetStepsToGo(drone.FreeLocation, order.Location) + 1;
     drone.FreeLocation = order.Location;
 }
 int GetStepsToDoneOrder(Drone drone, Warehouse warehouse, Order order)
 {
     return GetStepsToGo(drone.FreeLocation, warehouse.Location) + drone.LoadedProducts.Count() + 1 +
            GetStepsToGo(warehouse.Location, order.Location) + 1;
 }
        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;
        }
        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)
                    };
                }
            }
        }