add task solution#3324
Conversation
mateacademy-ai-mentor
left a comment
There was a problem hiding this comment.
Review Summary
The constructors use manual property assignment instead of TypeScript parameter properties with access modifiers. Apply 'public' (or another access modifier) before each parameter in the constructor to implicitly create the properties, as this is more concise and idiomatic TypeScript.
✨ 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
| constructor(color: FigureColor, a: number, b: number, c: number) { | ||
| validatePositiveLength(a, 'a'); | ||
| validatePositiveLength(b, 'b'); | ||
| validatePositiveLength(c, 'c'); | ||
|
|
||
| const sortedSides = [a, b, c].sort((x, y) => y - x); | ||
| const longestSide = sortedSides[0]; | ||
| const sumOfOtherSides = sortedSides[1] + sortedSides[2]; | ||
|
|
||
| if (longestSide >= sumOfOtherSides) { | ||
| throw new Error(`Sides ${a}, ${b} and ${c} can't form a triangle`); | ||
| } | ||
|
|
||
| this.color = color; | ||
| this.a = a; | ||
| this.b = b; | ||
| this.c = c; |
There was a problem hiding this comment.
This violates checklist item #4: Instead of manually assigning this.color = color, use TypeScript parameter properties by adding public (or another access modifier) before the parameter: constructor(public color: FigureColor, ...)
| constructor(color: FigureColor, radius: number) { | ||
| validatePositiveLength(radius, 'radius'); | ||
|
|
||
| this.color = color; | ||
| this.radius = radius; |
There was a problem hiding this comment.
This violates checklist item #4: Properties are manually assigned instead of using TypeScript parameter properties. Example fix: constructor(public color: FigureColor, public radius: number)
| constructor(color: FigureColor, width: number, height: number) { | ||
| validatePositiveLength(width, 'width'); | ||
| validatePositiveLength(height, 'height'); | ||
|
|
||
| this.color = color; | ||
| this.width = width; | ||
| this.height = height; |
There was a problem hiding this comment.
This violates checklist item #4: Properties are manually assigned instead of using TypeScript parameter properties. Example fix: constructor(public color: FigureColor, public width: number, public height: number)
mateacademy-ai-mentor
left a comment
There was a problem hiding this comment.
Review Summary
Your solution is approved. All task requirements have been successfully implemented: the Figure interface with proper shape and color types, the three shape classes with correct parameter properties, Heron's formula for triangles, Math.PI for circles, input validation with descriptive error messages, and the getInfo method formatting output as specified. The area calculation correctly rounds down to the hundredths place using Math.floor(area * 100) / 100. Great work on using TypeScript parameter properties with access modifiers to keep the code clean and concise!
✨ Please rate this review in the Platform's notification center1. I will be grateful for your feedback! ✨
No description provided.