dunwu / blog

:dart: 钝悟的博客
https://dunwu.github.io/blog/
Creative Commons Attribution Share Alike 4.0 International
861 stars 230 forks source link

没看懂有啥区别 #1

Closed songyichao closed 5 years ago

songyichao commented 5 years ago

image

dunwu commented 5 years ago

不好意思,出现了笔误。

解决部分的代码应该如下:

double calculateTotal() {
  if (basePrice() > 1000) {
    return basePrice() * 0.95;
  }
  else {
    return basePrice() * 0.98;
  }
}
double basePrice() {
  return quantity * itemPrice;
}