-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Solution #1647
base: master
Are you sure you want to change the base?
Solution #1647
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great job on implementing the Distance
class with all the necessary operator overloads! 🎉 Your code meets the task requirements and constraints effectively. While there are a few minor issues with type annotations and handling division by zero, these do not significantly impact the functionality. Keep up the good work, and consider addressing these minor points to enhance your code quality even further. Happy coding! 😊
✨ Please rate this review in the Platform's notification center. I will be grateful for your feedback! ✨
def __truediv__(self, other: (int, float)) -> "Distance": | ||
return Distance(round(self.km / other, 2)) | ||
|
||
def __lt__(self, other: Any) -> "Distance": |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The return type annotation for the __lt__
method should be bool
instead of "Distance"
, as this method returns a boolean value indicating whether the current instance is less than the other.
if isinstance(other, (int, float)): | ||
return self.km < other | ||
|
||
def __gt__(self, other: Any) -> "Distance": |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The return type annotation for the __gt__
method should be bool
instead of "Distance"
, as this method returns a boolean value indicating whether the current instance is greater than the other.
if isinstance(other, (int, float)): | ||
return self.km > other | ||
|
||
def __eq__(self, other: Any) -> "Distance": |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The return type annotation for the __eq__
method should be bool
instead of "Distance"
, as this method returns a boolean value indicating whether the current instance is equal to the other.
if isinstance(other, (int, float)): | ||
return self.km == other | ||
|
||
def __le__(self, other: Any) -> "Distance": |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The return type annotation for the __le__
method should be bool
instead of "Distance"
, as this method returns a boolean value indicating whether the current instance is less than or equal to the other.
if isinstance(other, (int, float)): | ||
return self.km <= other | ||
|
||
def __ge__(self, other: Any) -> "Distance": |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The return type annotation for the __ge__
method should be bool
instead of "Distance"
, as this method returns a boolean value indicating whether the current instance is greater than or equal to the other.
def __mul__(self, other: (int, float)) -> "Distance": | ||
return Distance(self.km * other) | ||
|
||
def __truediv__(self, other: (int, float)) -> "Distance": |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider adding a check to handle division by zero in the __truediv__
method to prevent runtime errors.
No description provided.