add task solution#3317
Conversation
mateacademy-ai-mentor
left a comment
There was a problem hiding this comment.
Review Summary
I am requesting changes to address the critical issues in your implementation.
Issue 1: Boundary validation inconsistency
The requirements state that an error should be thrown when "any length is <= 0", meaning zero must be rejected. However, Circle checks radius < 0 and Rectangle checks width < 0 || height < 0. Only Triangle correctly uses <= 0. Change these to <= 0 to match the requirements and ensure zero-length values are properly rejected.
Issue 2: Area rounding method
The requirements specify that area should be "rounded down to hundredths", which means using Math.floor, not Math.round. Your Rectangle and Triangle getArea methods currently use Math.round, which rounds to the nearest number instead of always rounding down. Use Math.floor(area * 100) / 100 consistently across all shape classes (Circle already does this correctly).
These two issues prevent your implementation from meeting the core functional requirements. Once fixed, your code will correctly validate inputs and produce the specified output format.
✨ Please rate this review in the Platform's notification center1. I will be grateful for your feedback! ✨
Important
Fix the issues, commit the changes, and then re-request my review using the Re-request review button2 in the Reviewers tab.
Tip
If you have any comments about this review, please leave a message in the Add a comment section below and mention me with the @mateacademy-ai-mentor tag3.
I will read your message during my next review of your pull request. Please do not reply directly to my comments, as that feature is not supported yet.
Caution
Do not close the pull request until the review is complete. Closing it early can lead to unexpected behavior and disrupt the review process.
Footnotes
| ) { | ||
| if (radius < 0) { |
There was a problem hiding this comment.
The validation uses < 0 but the requirements state that error should be thrown when 'any length is <= 0'. Zero should also be rejected. Change < 0 to <= 0 to match the requirements.
| ) { | ||
| if (width < 0 || height < 0) { |
There was a problem hiding this comment.
The validation uses < 0 but the requirements state that error should be thrown when 'any length is <= 0'. Zero should also be rejected. Change < 0 to <= 0 to match the requirements.
| getArea(): number { | ||
| return Math.round(this.width * this.height * 100) / 100; |
There was a problem hiding this comment.
The requirements specify that area should be 'rounded down to hundredths'. Using Math.round rounds to nearest, not down. Use Math.floor(area * 100) / 100 to round down, consistent with how Circle.getArea is implemented.
|
|
||
| return Math.round(area * 100) / 100; |
There was a problem hiding this comment.
The requirements specify that area should be 'rounded down to hundredths'. Using Math.round rounds to nearest, not down. Use Math.floor(area * 100) / 100 to round down, consistent with how Circle.getArea is implemented.
mateacademy-ai-mentor
left a comment
There was a problem hiding this comment.
Review Summary
Your solution is approved. All three figure classes (Triangle, Circle, Rectangle) properly implement the Figure interface with correct shape literal values and the color union type, and getArea() methods use Math.floor(area * 100) / 100 for consistent rounding. Validation is correctly implemented across all classes—you check for zero/negative dimensions and the triangle inequality rule. The constructors properly use TypeScript's public parameter modifiers for implicit property creation, and getInfo() produces the expected "A {color} {shape} - {area}" format. Great work addressing all the previous issues.
✨ Please rate this review in the Platform's notification center1. I will be grateful for your feedback! ✨
No description provided.