Ejemplo n.º 1
0
 public bool UnloadProduct(ProductType pt, int quantity)
 {
     if (Products.ContainsKey (pt) && Products[pt] >= quantity) {
         Products [pt] -= quantity;
         return true;
     } else {
         throw new Exception ("NO PRODUCT IN DRONE");
     }
     return false;
 }
Ejemplo n.º 2
0
        public int LoadProduct(ProductType pt, int quantity)
        {
            int q = CanLoadProduct(pt, quantity);

            if (Products.ContainsKey (pt)) {
                Products [pt] += q;
            } else {
                Products.Add (pt, q);
            }
            return q;
        }
Ejemplo n.º 3
0
        public int UnloadProduct(ProductType p, int qty)
        {
            if (!Products.ContainsKey (p))
                return 0;

            int maxQty = Math.Min (Products [p], qty);
            Products [p] -= maxQty;
            if (Products [p] == 0)
                Products.Remove (p);

            return maxQty;
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Base on the previsionnal inventory, retrieve the stock for a given product type
        /// </summary>
        /// <returns>The products.</returns>
        /// <param name="warehouse">Warehouse.</param>
        /// <param name="type">Type.</param>
        int RemainingProducts(WareHouse warehouse, ProductType type)
        {
            // Get the wh prev inventory
            var inv = Inventories [warehouse];

            // How many product of this type left?
            var remainingProduct = 0;
            inv.TryGetValue(type, out remainingProduct);

            return remainingProduct;
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Create a monoProduct order and update the inventory
        /// </summary>
        /// <param name="warehouse">Warehouse.</param>
        /// <param name="cell">Cell.</param>
        /// <param name="type">Type.</param>
        /// <param name="qtt">Qtt.</param>
        void PlaceOrder(WareHouse warehouse, Cell cell, ProductType type, int qtt)
        {
            var detail = new Dictionary<ProductType, int>();
            detail.Add(type, qtt);

            Order order = new Order(detail, cell);

            Affect(order, warehouse);

            var inv = Inventories [warehouse];

            var value = inv [type];

            value -= qtt;

            if(value == 0)
            {
                inv.Remove(type);
            }
            else
            {
                inv [type] = value;
            }
        }
Ejemplo n.º 6
0
 public int CanLoadProduct(ProductType pt, int quantity)
 {
     return Math.Min(MaxWeight, Weight + (pt.Weight * quantity));
 }