25 lines
531 B
Python
25 lines
531 B
Python
from __future__ import annotations
|
|
|
|
class Vector2:
|
|
def __init__(self, x, y) -> None:
|
|
self.__x = x
|
|
self.__y = y
|
|
|
|
@property
|
|
def x(self):
|
|
return self.__x
|
|
|
|
@property
|
|
def y(self):
|
|
return self.__y
|
|
|
|
def __add__(self, other: Vector2) -> Vector2:
|
|
return Vector2(self.x + other.x, self.y + other.y)
|
|
|
|
def __eq__(self, other) -> bool:
|
|
return self.x == other.x and self.y == other.y
|
|
|
|
def __str__(self) -> str:
|
|
return f"{self.x}; {self.y}"
|
|
|
|
|