Пример #1
0
        public bool AddCargo(Cargo cargo)
        {
            bool cargoAdded = false;

            if (CargoSizeUsed + (cargo.Mass * cargo.Quantity) <= CargoSizeMax)
            {
                Cargo existingCargo = Cargo.Find(item => item.Name == cargo.Name);
                if (existingCargo != null)
                    existingCargo.Quantity += cargo.Quantity;
                else
                    Cargo.Add(cargo);

                cargoAdded = true;
            }

            return cargoAdded;
        }
Пример #2
0
        public bool RemoveCargo(Cargo cargo)
        {
            bool cargoRemoved = false;

            if (cargo != null)
                cargoRemoved = RemoveCargo(cargo.Name, cargo.Quantity);

            return cargoRemoved;
        }