Skip to content
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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Solution #1647

wants to merge 1 commit into from

Conversation

Bogdannna7
Copy link

No description provided.

Copy link

@mateacademy-ai-mentor mateacademy-ai-mentor left a 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":

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":

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":

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":

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":

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":

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants