Last active
December 12, 2017 12:17
-
-
Save srakrn/370f49f5f120cf554998b9758f2c141c to your computer and use it in GitHub Desktop.
A (bad) example on Python's OOP, both showing its OOP ability, and showing that not all problems needs implementation of OOP concept.
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
class GCDCalculator: | |
def __init__(self, x, y): | |
self.x = x | |
self.y = y | |
self.gcd = self.gcd_function(x, y) | |
def gcd_function(self, x, y): | |
while y: | |
x, y = y, x%y | |
return x | |
x = int(input()) | |
y = int(input()) | |
xy_gcd_object = GCDCalculator(x, y) | |
print(xy_gcd_object.gcd) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment