3 案例

public static void price(LocalDate aDate, Plan plan, Long quantity) {  if (!aDate.isBefore(plan.summerStart) && !aDate.isAfter(plan.summerEnd)) {    charge = quantity * plan.summerRate;  } else {    charge = quantity * plan.regularRate + plan.regularServiceCharge;  }}

/**     * 在冬季和夏季的单价不同     */    public static void price(LocalDate aDate, Plan plan, Long quantity) {        if (summer(aDate, plan)) {            charge = quantity * plan.summerRate;        } else {            charge = quantity * plan.regularRate + plan.regularServiceCharge;        }    }    public static boolean summer(LocalDate aDate, Plan plan) {        return !aDate.isBefore(plan.summerStart) && !aDate.isAfter(plan.summerEnd);    }

/** * 在冬季和夏季的单价不同 */public static void price(LocalDate aDate, Plan plan, Long quantity) {  if (summer(aDate, plan)) {    charge = summerCharge(plan, quantity);  } else {    charge = quantity * plan.regularRate + plan.regularServiceCharge;  }}/** * 提炼条件判断为真的分支 */public static Long summerCharge(Plan plan, Long quantity) {  return quantity * plan.summerRate;}}

/** * 在冬季和夏季的单价不同 */public static void price(LocalDate aDate, Plan plan, Long quantity) {  if (summer(aDate, plan)) {    charge = summerCharge(plan, quantity);  } else {    charge = regularCharge(plan, quantity);  }}private static Long regularCharge(Plan plan, Long quantity) {  return quantity * plan.regularRate + plan.regularServiceCharge;}

/** * 在冬季和夏季的单价不同 */public static void price(LocalDate aDate, Plan plan, Long quantity) {  charge = summer(aDate, plan) ? summerCharge(plan, quantity) : regularCharge(plan, quantity);}