Skip to content
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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Solved #1765

wants to merge 1 commit into from

Conversation

abeshle
Copy link

@abeshle abeshle commented Dec 21, 2024

No description provided.

Copy link

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

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);

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);

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.

Comment on lines +12 to +19
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))};

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;

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.

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