-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathpoint.py
More file actions
29 lines (23 loc) · 786 Bytes
/
point.py
File metadata and controls
29 lines (23 loc) · 786 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
class Point:
"""
Defines the blueprint of a specific point on the word grid. This point will be used to mark the position of
a word on the cartesian plane.
"""
def __init__(self, x, y):
"""
Creates a new cartesian point object
:param x: point on x-axis
:param y: point on y-axis
"""
self.x = x
self.y = y
def __repr__(self):
return "Point({}:{})".format(self.x, self.y)
def __add__(self, other):
return Point(self.x + other.x, self.y + other.y)
def __sub__(self, other):
return Point(self.x - other.x, self.y - other.y)
def __eq__(self, other):
return self.x == other.x and self.y == other.y
def __ne__(self, other):
return not (self == other)