Skip to content

add task solution#3317

Open
bodyafell wants to merge 2 commits into
mate-academy:masterfrom
bodyafell:develop
Open

add task solution#3317
bodyafell wants to merge 2 commits into
mate-academy:masterfrom
bodyafell:develop

Conversation

@bodyafell
Copy link
Copy Markdown

No description provided.

Copy link
Copy Markdown

@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.

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

  1. Rate AI review example

  2. Re-request AI review example

  3. Add AI review comments example

Comment thread src/figuresClasses.ts Outdated
Comment on lines +42 to +43
) {
if (radius < 0) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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.

Comment thread src/figuresClasses.ts Outdated
Comment on lines +60 to +61
) {
if (width < 0 || height < 0) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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.

Comment thread src/figuresClasses.ts Outdated
Comment on lines +66 to +67
getArea(): number {
return Math.round(this.width * this.height * 100) / 100;
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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.

Comment thread src/figuresClasses.ts Outdated
Comment on lines +31 to +32

return Math.round(area * 100) / 100;
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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.

Copy link
Copy Markdown

@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.

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! ✨

Footnotes

  1. Rate AI review example

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