Created
January 23, 2015 15:51
-
-
Save hidenorigoto/5940bd195094fc3a6182 to your computer and use it in GitHub Desktop.
refactoring sample
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if (date.before(SUMMER_START) || date.after(SUMMER_END)) | |
charge = quantity * _winterRate + _winterServiceCharge; | |
else charge = quantity * _summerRate; | |
if (notSummer(date)) | |
charge = winterCharge(quantity); | |
else charge = summerCharge(quantity); | |
private boolean notSummer(Date date) { | |
return date.before(SUMMER_START) || date.after(SUMMER_END); | |
} | |
private double summerCharge(int quantity) | |
{ | |
return quantity * _summerRate; | |
} | |
private double winterCharge(int quantity) | |
{ | |
return quantity * _winterRate + _winterServiceCharge; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment