コード例 #1
0
        /// <summary>
        /// Lend equipment to diver
        /// </summary>
        /// <param name="dive"></param>
        /// <param name="diver"></param>
        private void LendEquipment(Dive dive, Diver diver)
        {
            // If diver already have this equipment then just extend loan date
            if (diver.CheckIfDiverHaveEquipment(this))
            {
                SetLoanDate(dive);
            }

            // Else if equipment is available and diver does not have equipment from that category
            else if (IsEquipmentAvailable() && !diver.CheckExistingEquipmentByCategory(ID) && !diver.CheckIfDiverHaveEquipment(this))
            {
                // Add equipment to diver
                diver.AddEquipment(this);

                // Set loan date
                SetLoanDate(dive);

                // Reduce stock
                stock--;
            }
        }