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

py-distance-class task #1784

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

Conversation

Grzechu700
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! 🎉 Your code meets the task requirements and constraints, and you've done well to include all the necessary magic methods. While there are a couple of areas for improvement, such as handling division by zero in the __truediv__ method and allowing the __sub__ method to handle subtraction with integers or floats, these are minor issues that don't significantly impact the core functionality. Keep up the good work, and consider these enhancements for future robustness and consistency! 😊

✨ Please rate this review in the Platform's notification center. I will be grateful for your feedback! ✨

Comment on lines +17 to +20
def __sub__(self, other: "Distance") -> "Distance":
if isinstance(other, Distance):
return Distance(self.km - other.km)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The __sub__ method currently only handles subtraction with another Distance object. To maintain consistency with other methods, consider adding support for subtracting an integer or float.

Comment on lines +21 to +23
def __truediv__(self, other: float) -> "Distance":
if isinstance(other, (int, float)):
return Distance(round(self.km / other, 2))

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The __truediv__ method should handle division by zero to prevent runtime errors. Consider adding a check to raise an exception if other is zero.

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