67,513
社区成员
发帖
与我相关
我的任务
分享
double getPrice(){
int basePaice=quantity*ite3mPrice;
double discountFactor;
if(basePrice>1000)discountFactor=0.95;
else discountFactor=0.98;
return basePrice * discountFactor;
}
//这个方法被重构成
double getPrice(){
double discountFactor;
if(basePrice()>1000)discountFactor=0.95;
else discountFactor=0.98;
return basePrice()* discountFactor;
}
double basePrice(){
return quantity*ite3mPrice;
}