console_snake/point.py

20 lines
480 B
Python
Raw Permalink Normal View History

2022-10-26 21:57:29 +03:00
class Point:
def __init__(self, x, y):
self.x = x
self.y = y
def __eq__(self, other) -> bool:
2022-10-29 04:25:09 +03:00
if not isinstance(other, Point):
return False
if self.x == other.x and self.y == other.y:
return True
2022-10-26 21:57:29 +03:00
else:
2022-10-29 04:25:09 +03:00
return False
2022-10-26 21:57:29 +03:00
2022-10-26 23:43:49 +03:00
def __hash__(self) -> int:
2022-10-26 22:56:34 +03:00
return int(f"{abs(self.x)}000{abs(self.y)}")
2022-10-26 21:57:29 +03:00
def __str__(self) -> str:
return f"{self.x = } | {self.y = }"