From ff5742b08c0fd58ef6ee0b01297ffa37110d8242 Mon Sep 17 00:00:00 2001 From: Pascal Lais Date: Wed, 11 Mar 2020 12:50:22 +0100 Subject: [PATCH] Update 'point.py' Add __eq__ operator to class point --- point.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/point.py b/point.py index 5f4d520..010929f 100644 --- a/point.py +++ b/point.py @@ -21,6 +21,9 @@ class Point(): def get_y(self): """Returns the Y-Coordinate of the Point""" return self.__y + def __eq__(self, other) + """Returns True if the points coordinates are the same, else returns False""" + return self.get_x() == other.get_x() and self.get_y() == other.get_y() def __str__(self): """Returns the coordinates as a string""" return "(" + str(self.get_x()) + "/" + str(self.get_y()) + ")"