Created
July 9, 2012 06:14
-
-
Save jhgaylor/3074496 to your computer and use it in GitHub Desktop.
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
| class Point: | |
| def __init__(self, x, y): | |
| self.x = x | |
| self.y = y | |
| def __str__(self): | |
| return str(self.x) + ", " + str(self.y) | |
| def __lt__(self, other): | |
| if self.x < other.x: | |
| return True | |
| else: | |
| return False | |
| def __eq__(self,other): | |
| if self.x == other.x: | |
| if self.y == other.y: | |
| return True | |
| return False | |
| def __gt__(self, other): | |
| if self.x > other.x: | |
| return True | |
| else: | |
| return False | |
| def isLT(self, other): | |
| if self.x > other.x: | |
| return True | |
| else: | |
| return False | |
| def distance(self, other): | |
| if self.x is none or self.y is none or other.x is none or other.y is none: | |
| raise Exception | |
| else: | |
| return ((self.x-other.x)**2 + (self.y-other.y)**2)**(0.5) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment