Пример #1
0
        /// <summary>
        /// Update diver equipment status
        /// FULLY EQUIPED       - basic equipment + all additional equipment
        /// PARTIALLY EQUIPED   - basic equipment
        /// NOT EQUIPED         - without basic equipment
        /// </summary>
        public void UpdateEquipmentStatus(Dive dive)
        {
            int basicEquipmentCounter = 0;

            // Check if user have all basic equipment
            foreach (ConcreteEquipment equipment in equipmentList)
            {
                if (EquipmentHelper.IsBasicEquipment(equipment))
                {
                    basicEquipmentCounter++;
                }
            }

            // Basic equipment
            if (basicEquipmentCounter == Constants.NUM_OF_BASIC_EQUIPMENT && equipmentList.Count() == Constants.NUM_OF_BASIC_EQUIPMENT)
            {
                equipmentStatus = Constants.PARTIALLY_EQUIPED;
            }

            // Diver is not adequate equiped for dive
            else if (basicEquipmentCounter < Constants.NUM_OF_BASIC_EQUIPMENT)
            {
                equipmentStatus = Constants.NOT_EQUIPED;
            }

            // Basic + additional equipment
            else if (
                // If it's cold dive then check if diver is adequate equipped for cold dive
                (dive.temperature < Constants.TEMPERATURE_BOUNDARY && EquipmentHelper.IsDiverAdequatEquippedForColdDive(equipmentList)) ||

                // If it's dive with temp above 15 and diver is adequate equipped for that dive
                (dive.temperature >= Constants.TEMPERATURE_BOUNDARY && EquipmentHelper.IsDiverAdequateEquippedForWarmDive(equipmentList)) &&

                // If it's night dive then check if diver is adequate equipped for night dive
                ((dive.isNightDive && EquipmentHelper.IsDiverAdequateEquippedForNightDive(EquipmentList)) || !dive.isNightDive)
                )
            {
                equipmentStatus = Constants.FULLY_EQUIPED;
            }
        }