コード例 #1
0
 public void EquipDiver(Diver diver, Dive dive)
 {
     // Equip with basic equipment
     if (diver.IsBasicEquipmentAssociation() == true &&
         temperature == "#" &&
         needForRecording == "#" &&
         needForNightDive == "#" &&
         stock > 0 &&
         !diver.CheckExistingEquipmentByCategory(ID))
     {
         diver.AddEquipment(this);
         stock--;
     }
     // Equip with dry suits
     if (dive.GetTemperature() < 15 &&
         (ID.StartsWith("1.1.3.") || ID.StartsWith("1.2.") || ID.StartsWith("1.4.") || (ID.StartsWith("1.3.") && temperature != "#" && Int32.Parse(temperature) < 15)) &&
         stock > 0 &&
         !diver.CheckExistingEquipmentByCategory(ID))
     {
         diver.AddEquipment(this);
         stock--;
     }
     // Equip with wet suits
     else if (dive.GetTemperature() >= 15 &&
              (ID.StartsWith("1.1.1.") || ID.StartsWith("1.1.2.") || (ID.StartsWith("1.3.") && temperature != "#" && Int32.Parse(temperature) >= 15)) &&
              stock > 0 &&
              !diver.CheckExistingEquipmentByCategory(ID))
     {
         diver.AddEquipment(this);
         stock--;
     }
     // Equip with equipment for night dive
     if (dive.IsNightDive() == true &&
         needForNightDive == "*" &&
         !diver.CheckExistingEquipmentByCategory(ID))
     {
         diver.AddEquipment(this);
         stock--;
     }
     // Equip with equipment for fotographers
     if (diver.CheckIfDiverHasSuperPower("Podvodni fotograf") == true &&
         needForRecording == "*" &&
         !diver.CheckExistingEquipmentByCategory(ID))
     {
         diver.AddEquipment(this);
         stock--;
     }
 }
コード例 #2
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--;
            }
        }