Skip to content

Instantly share code, notes, and snippets.

@fuwiak
Created July 4, 2023 20:04
Show Gist options
  • Save fuwiak/3445b3c2dbbcbdadf6a0fd47f37fc06c to your computer and use it in GitHub Desktop.
Save fuwiak/3445b3c2dbbcbdadf6a0fd47f37fc06c to your computer and use it in GitHub Desktop.
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