Created
July 4, 2023 20:04
-
-
Save fuwiak/3445b3c2dbbcbdadf6a0fd47f37fc06c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Vector2D: | |
def __init__(self, x, y): | |
self.x = x | |
self.y = y | |
def __str__(self): | |
return f"Vector2D({self.x}, {self.y})" | |
def __add__(self, other): | |
if isinstance(other, Vector2D): | |
return Vector2D(self.x + other.x, self.y + other.y) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment