I have a series of 8 "knockout" if statements that must pass in order to show the appropriate response. If any one of these 8 if statements are failed, the appropriate response is shown. Below is my code...
if (ageCustInt >= ageMinComp1Int && ageCustInt <= ageMaxComp1Int){
if(adtV1MileageCustInt >= adtVMileageMinComp1Int && adtV2MileageCustInt >= adtVMileageMinComp1Int && adtV3MileageCustInt >= adtVMileageMinComp1Int &&
adtV1MileageCustInt <= adtVMileageMaxComp1Int && adtV2MileageCustInt <= adtVMileageMaxComp1Int && adtV3MileageCustInt <= adtVMileageMaxComp1Int)
if(totalViolationsCustInt >= totalViolationsMinComp1Int && totalViolationsCustInt <= totalViolationsMaxComp1Int)
if(totalAdtDriversCustInt >= adtDriversMinComp1Int && totalAdtDriversCustInt <= adtDriversMaxComp1Int)
if(bodilyInjuryCust.equals(bodilyInjuryComp1))
if(propDamageCust.equals(propDamageComp1))
if(currentInsur.equals(presInsurKOComp1) || presInsurKOComp1.equals("Both"))
if(unUiBodilyCust.equals(unUiBodilyComp1))
{
btnComp1.setVisible(true);
lblPriceComp1.setText("$ " + price1String);
lblPriceComp1.setVisible(true);
}
} else
{
lblPriceComp1.setText("Not Competitive");
}
I am getting mostly correct results, but every now and then the appropriate "not competitive" result from the else block is not being displayed as it should. My guess here is because the else statement only applies to the very first if statement, and if that is passed than the else block is not executed. I need to structure my if statements so that if ANY of the if statements are failed the else block will execute. I have tried restructuring my blocks with no success. Any ideas?
Aucun commentaire:
Enregistrer un commentaire