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

Solutionn #1655

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

Solutionn #1655

wants to merge 1 commit into from

Conversation

IllyaKovaliuk
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 all the task requirements and constraints, including the correct use of magic methods and type annotations. Just a small note: when returning NotImplemented for unsupported operations, ensure that the calling code handles this correctly to prevent any unexpected behavior. Keep up the excellent work! 😊

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

return Distance(self.km + other.km)
elif isinstance(other, (int, float)):
return Distance(self.km + other)
return NotImplemented

Choose a reason for hiding this comment

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

Returning NotImplemented is correct for unsupported operations, but ensure that this behavior is handled properly in the calling code to avoid unexpected results.

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

Choose a reason for hiding this comment

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

Returning NotImplemented is appropriate here, but make sure the calling code handles this case to prevent errors.

def __truediv__(self, divisor: float) -> Distance:
if isinstance(divisor, (int, float)) and divisor != 0:
return Distance(round(self.km / divisor, 2))
return NotImplemented

Choose a reason for hiding this comment

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

Returning NotImplemented is suitable for unsupported operations. Ensure that the calling code can handle this return value correctly.

return self.km < other.km
elif isinstance(other, (int, float)):
return self.km < other
return NotImplemented

Choose a reason for hiding this comment

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

Returning NotImplemented is appropriate for unsupported comparisons. Ensure that this is handled in the calling code to avoid issues.

return self.km <= other.km
elif isinstance(other, (int, float)):
return self.km <= other
return NotImplemented

Choose a reason for hiding this comment

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

Returning NotImplemented is correct for unsupported comparisons. Ensure that this is handled properly in the calling code.

return self.km == other.km
elif isinstance(other, (int, float)):
return self.km == other
return NotImplemented

Choose a reason for hiding this comment

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

Returning NotImplemented is suitable for unsupported comparisons. Make sure the calling code handles this correctly.

return self.km != other.km
elif isinstance(other, (int, float)):
return self.km != other
return NotImplemented

Choose a reason for hiding this comment

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

Returning NotImplemented is appropriate for unsupported comparisons. Ensure that this is handled in the calling code.

return self.km > other.km
elif isinstance(other, (int, float)):
return self.km > other
return NotImplemented

Choose a reason for hiding this comment

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

Returning NotImplemented is correct for unsupported comparisons. Ensure that this is handled properly in the calling code.

return self.km >= other.km
elif isinstance(other, (int, float)):
return self.km >= other
return NotImplemented

Choose a reason for hiding this comment

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

Returning NotImplemented is suitable for unsupported comparisons. Make sure the calling code handles this correctly.

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