double GetPrice()
{
int basePrice = _quantity * _itemPrice;
double discountFactor;
if (basePrice > )
{
discountFactor = 0.95;
}
else
{
discountFactor = 0.98;
}
return basePrice * discountFactor;
}
double GetPrice()
{
return BasePrice() * DiscountFactor();
} int BasePrice()
{
return _quantity * _itemPrice;
} double DiscountFactor()
{
if (BasePrice() > )
{
return 0.95;
}
else
{
return 0.98;
}
}
参考:http://sourcemaking.com/refactoring/replace-temp-with-query