Skip to content

Commit

Permalink
'Solution'
Browse files Browse the repository at this point in the history
  • Loading branch information
Hermesvlad committed Oct 21, 2023
1 parent b5a2f54 commit 71052f6
Showing 1 changed file with 9 additions and 16 deletions.
25 changes: 9 additions & 16 deletions app/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,40 +24,33 @@ def __iadd__(self, other: Distance | int | float) -> Distance:
self.km += other
return self

def __mul__(self, other: Distance | int | float) -> Distance:
if isinstance(other, (int, float)):
return Distance(self.km * other)
def __mul__(self, other: int | float) -> Distance:
return Distance(self.km * other)

def __truediv__(self, other: Distance | int | float) -> Distance:
if isinstance(other, (int, float)):
return Distance(round(self.km / other, 2))
def __truediv__(self, other: int | float) -> Distance:
return Distance(round(self.km / other, 2))

def __eq__(self, other: Distance | int | float) -> Distance:
if isinstance(other, Distance):
return self.km == other.km
elif isinstance(other, (int, float)):
return self.km == other
return self.km == other

def __lt__(self, other: Distance | int | float) -> Distance:
if isinstance(other, Distance):
return self.km < other.km
elif isinstance(other, (int, float)):
return self.km < other
return self.km < other

def __gt__(self, other: Distance | int | float) -> Distance:
if isinstance(other, Distance):
return self.km > other.km
elif isinstance(other, (int, float)):
return self.km > other
return self.km > other

def __le__(self, other: Distance | int | float) -> Distance:
if isinstance(other, Distance):
return self.km <= other.km
elif isinstance(other, (int, float)):
return self.km <= other
return self.km <= other

def __ge__(self, other: Distance | int | float) -> Distance:
if isinstance(other, Distance):
return self.km >= other.km
elif isinstance(other, (int, float)):
return self.km >= other
return self.km >= other

0 comments on commit 71052f6

Please sign in to comment.