Skip to content

added solution#3319

Open
Inna-code10 wants to merge 3 commits into
mate-academy:masterfrom
Inna-code10:develop
Open

added solution#3319
Inna-code10 wants to merge 3 commits into
mate-academy:masterfrom
Inna-code10:develop

Conversation

@Inna-code10
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

The JSON response contains markdown text and is not valid. It must be a plain JSON object with 'decision' and 'reason' fields matching the specified schema.


✨ 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 +28 to +33
getArea(): number {
const p = (this.a + this.b + this.c) / 2;

const area = Math.sqrt(p * (p - this.a) * (p - this.b) * (p - this.c));

return Number(area.toFixed(2));
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 task requires area rounded down to hundredths, but toFixed(2) rounds to nearest. For rounding down, use Math.floor(area * 100) / 100 pattern (similar to the Circle implementation on line 49).

Comment thread src/figuresClasses.ts Outdated
Comment on lines +67 to +68
getArea(): number {
return Number((this.width * this.height).toFixed(2));
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 task requires area rounded down to hundredths, but toFixed(2) rounds to nearest. Use Math.floor(this.width * this.height * 100) / 100 to round down.

Comment thread src/figuresClasses.ts Outdated
Comment on lines +17 to +18
if (a <= 0 || b <= 0 || c <= 0) {
throw new Error('your error message');
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Checklist item #3 requires detailed, descriptive error messages. Replace 'your error message' with something like 'All sides must be greater than 0'.

Comment thread src/figuresClasses.ts Outdated
Comment on lines +23 to +24
if (maxSide >= a + b + c - maxSide) {
throw new Error('your error message');
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Checklist item #3 requires detailed, descriptive error messages. Replace 'your error message' with something like 'Sides {a}, {b} and {c} cannot form a triangle'.

Comment thread src/figuresClasses.ts Outdated
Comment on lines +44 to +45
if (radius <= 0) {
throw new Error('your error message');
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Checklist item #3 requires detailed, descriptive error messages. Replace 'your error message' with something like 'Radius must be greater than 0'.

Comment thread src/figuresClasses.ts Outdated
Comment on lines +62 to +63
if (width <= 0 || height <= 0) {
throw new Error('your error message');
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Checklist item #3 requires detailed, descriptive error messages. Replace 'your error message' with something like 'Width and height must be greater than 0'.

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 implementation has solid logic for area calculations, proper error handling, and correct validation. However, the code does not meet the explicit requirements for enum usage.

Critical issues that must be fixed:

  1. Missing Shape enum — The requirements explicitly state: "Use enum for shape with values: Triangle, Circle, Rectangle". Currently, your code uses string literals like 'triangle', 'circle', 'rectangle'. You need to define a Shape enum and use it in your Figure interface and all implementing classes.

  2. Missing Color enum — The requirements explicitly state: "Use enum for color with values: Red, Green, Blue". Currently, your code uses the plain string type. You need to define a Color enum and use it for the color property throughout your implementation.

How to fix:

Define the enums at the top of your file:

enum Shape { Triangle, Circle, Rectangle }
enum Color { Red, Green, Blue }

Then update your Figure interface and class properties to use these enums instead of string types.

All your functional logic is correct — just add the enum definitions to meet the requirements.


✨ 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 +8 to +9
export class Triangle implements Figure {
shape = 'triangle';
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 code uses string literals for shape properties instead of enums. Requirements specify: 'Use enum for shape with values: Triangle, Circle, Rectangle'. The shape should be typed using a Shape enum.

Comment thread src/figuresClasses.ts Outdated
shape = 'triangle';

constructor(
public color: string,
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 code uses plain string type for color instead of an enum. Requirements specify: 'Use enum for color with values: Red, Green, Blue'. The color property should be typed using a Color enum.

Comment thread src/figuresClasses.ts Outdated
shape = 'circle';

constructor(
public color: string,
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 code uses plain string type for color instead of an enum. Requirements specify: 'Use enum for color with values: Red, Green, Blue'. The color property should be typed using a Color enum.

Comment thread src/figuresClasses.ts Outdated
shape = 'rectangle';

constructor(
public color: string,
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 code uses plain string type for color instead of an enum. Requirements specify: 'Use enum for color with values: Red, Green, Blue'. The color property should be typed using a Color enum.

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. Excellent implementation of the Figure interface with all three shape classes properly implementing the required getArea method. The enums use correct naming conventions (capitalized constants with lowercase string values), validation logic handles edge cases appropriately (positive dimensions and triangle inequality), and the area calculations are accurate using Heron's formula and Math.PI. The getInfo function produces the expected output format, and the use of constructor parameter modifiers (public color) follows TypeScript best practices [CHECKLIST ITEM #4]. Well done!


✨ 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