-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Solved #1765
base: master
Are you sure you want to change the base?
Solved #1765
Conversation
There was a problem hiding this 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 task! 🎉 Your code meets the core requirements and functions as expected. While there are a few areas for improvement, such as refining the formulas for the area calculations and enhancing code readability by avoiding magic numbers and using more expressive methods, these are minor issues that don't impact the overall functionality. Keep up the good work, and consider these suggestions to further polish your code in future projects! 😊
✨ Please rate this review in the Platform's notification center. I will be grateful for your feedback! ✨
|
||
@Override | ||
public double area() { | ||
return Math.PI * (radius * radius); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The formula for the area of a circle should be Math.PI * Math.pow(radius, 2)
instead of Math.PI * (radius * radius)
. Although both are mathematically equivalent, using Math.pow
is more expressive and aligns with common mathematical notation.
public Figure getRandomFigure() { | ||
ColorSupplier colorSupplier = new ColorSupplier(); | ||
Random random = new Random(); | ||
int figureNumber = random.nextInt(5); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider defining the number of figures as a constant, as suggested in the checklist: "All magic numbers in your code should be constants." This will improve code readability and maintainability.
new IsoscelesTrapezoid(colorSupplier.getRandomColor(),random.nextInt(10), | ||
random.nextInt(10), random.nextInt(7)), | ||
new Circle(colorSupplier.getRandomColor(), random.nextInt(10)), | ||
new Rectangle(colorSupplier.getRandomColor(), random.nextInt(10), | ||
random.nextInt(10)), | ||
new RightTriangle(colorSupplier.getRandomColor(), random.nextInt(10), | ||
random.nextInt(7)), | ||
new Square(colorSupplier.getRandomColor(), random.nextInt(10))}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of passing expressions directly into the constructors, consider creating separate variables for each parameter. This will enhance code readability and align with the checklist recommendation: "Creating a figure, don't pass expressions in the constructor. Create separate variables and pass them on for better code readability."
|
||
@Override | ||
public double area() { | ||
return (double) (firstSide * secondSide / 2) * height; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The formula for the area of an isosceles trapezoid should be ((firstSide + secondSide) / 2.0) * height
instead of (firstSide * secondSide / 2) * height
. The current formula is incorrect and will not yield the correct area.
No description provided.