hnc-eduard/HNS/Excercises/Magic/Point.py

28 lines
625 B
Python

from math import sqrt
class Point:
def __init__(self, x, y):
self.x = x
self.y = y
def __str__(self):
return '(' + str(self.x) + '|' + str(self.y) + ')'
def __eq__(self, other):
if type(other) is Point:
return self.x == other.x and self.y == other.y
return False
def __ne__(self, other):
return not self.__eq__(other)
def _intern(self):
return self.x + 42
def distance(self, point):
if type(point) is Point:
return sqrt((self.x - point.x) ** 2 + (self.y - point.y) ** 2)
else:
return 0