Exemplo n.º 1
0
 private void LoadOrder(Order order)
 {
     var a = ReadLineAsArrayOfInts();
     order.Location = new Coordinate(a[0], a[1]);
     var numberOfItems = ReadLineAsArrayOfInts().First();
     LoadOrderProducts(order.Products);
 }
Exemplo n.º 2
0
 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;
 }
Exemplo n.º 3
0
 int GetStepsToDoneOrder(Drone drone, Warehouse warehouse, Order order)
 {
     return GetStepsToGo(drone.FreeLocation, warehouse.Location) + drone.LoadedProducts.Count() + 1 +
            GetStepsToGo(warehouse.Location, order.Location) + 1;
 }
Exemplo n.º 4
0
        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;
        }
Exemplo n.º 5
0
        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)
                    };
                }
            }
        }