Last active
January 9, 2019 12:23
-
-
Save maciejjankowski/536d2031faeeaab765b98008b48a45eb to your computer and use it in GitHub Desktop.
Refactoring exercises
This file contains 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
# https://github.com/RefactoringGuru/refactoring-examples/tree/master/simple/python | |
# 1 | |
def disabilityAmount(): | |
if seniority < 2: | |
return 0 | |
if monthsDisabled > 12: | |
return 0 | |
if isPartTime: | |
return 0 | |
# 2 | |
if isSpecialDeal(): | |
total = price * 0.95 | |
send() | |
else: | |
total = price * 0.98 | |
send() | |
# 3 | |
if date.before(SUMMER_START) or date.after(SUMMER_END): | |
charge = quantity * winterRate + winterServiceCharge | |
else: | |
charge = quantity * summerRate | |
# 4 | |
def printOwing(self): | |
self.printBanner() | |
# print details | |
print("name:", self.name) | |
print("amount:", self.getOutstanding()) | |
# 5 | |
def discount(inputVal, quantity): | |
if inputVal > 50: | |
inputVal -= 2 | |
return inputVal |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment