Projekt_AI-Automatyczny_saper/Engine/Point.py

27 lines
656 B
Python
Raw Normal View History

2021-03-15 19:04:51 +01:00
class Point:
2021-03-27 22:07:55 +01:00
def __init__(self, x, y):
self.x = x
self.y = y
def getY(self):
return self.y
def getX(self):
return self.x
2021-04-12 22:54:33 +02:00
def distance(self,endpoint):
return abs(self.getX() + endpoint.getX()) + abs(self.getY() + endpoint.getY())
2021-03-27 22:07:55 +01:00
def __hash__(self):
"""Overrides the default implementation"""
return hash(tuple(sorted(self.__dict__.items())))
def __eq__(self, other):
if isinstance(other, self.__class__):
return self.__dict__ == other.__dict__
else:
return False
def __ne__(self, other):
return not self.__eq__(other)