Skip to content

Instantly share code, notes, and snippets.

@afrinjamanbd
Last active June 18, 2022 14:47
Show Gist options
  • Save afrinjamanbd/e6455aed37a13644afef6b81991b5efa to your computer and use it in GitHub Desktop.
Save afrinjamanbd/e6455aed37a13644afef6b81991b5efa to your computer and use it in GitHub Desktop.
Wrong_Method_Chain.
class Calculator():
def __init__(self, variable):
self.variable = variable
def add(self, adition):
total = self.variable + adition
print(total)
print ("Calculator.add() function called")
return total
def sub(self, subtraction):
total = self.variable - subtraction
print(total)
print ("Calculator.sub() function called")
return total
def mul(self, multiplication):
total = self.variable * multiplication
print(total)
print ("Calculator.mul() function called")
return total
def div(self, division):
total = self.variable / division
print(total)
print ("Calculator.div() function called")
return total
a = 10
calc = Calculator(a)
calc = calc.add(1)
calc2 = Calculator(a)
calc2= calc2.mul(2)
cal = Calculator(a)
cal = cal.add(6).sub(10).mul(2).div(3)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment