Coordinate.__mul__, Coordinate.__truediv__, Coordinate.__floordiv__
This commit is contained in:
parent
ec64dce347
commit
cc9a6bcbc5
@ -176,6 +176,21 @@ class Coordinate:
|
||||
else:
|
||||
return self.__class__(self.x - other.x, self.y - other.y, self.z - other.z)
|
||||
|
||||
def __mul__(self, other: int) -> Coordinate:
|
||||
if self.z is None:
|
||||
return self.__class__(self.x * other, self.y * other)
|
||||
else:
|
||||
return self.__class__(self.x * other, self.y * other, self.z * other)
|
||||
|
||||
def __floordiv__(self, other) -> Coordinate:
|
||||
if self.z is None:
|
||||
return self.__class__(self.x // other, self.y // other)
|
||||
else:
|
||||
return self.__class__(self.x // other, self.y // other, self.z // other)
|
||||
|
||||
def __truediv__(self, other):
|
||||
return self // other
|
||||
|
||||
def __eq__(self, other):
|
||||
if not isinstance(other, Coordinate):
|
||||
return False
|
||||
|
||||
Loading…
Reference in New Issue
Block a user