分解条件语句

refactorgram

if (!aDate.isBefore(plan.summerStart) && !aDate.isAfter(plan.summerEnd))
  charge = quantity * plan.summerRate;
else
  charge = quantity * plan.regularRate + plan.regularServiceCharge;

image/svg+xml

if (summer())
  charge = summerCharge();
else
  charge = regularCharge();