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

Figures are calculated! #1776

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

Anastasiia2025
Copy link

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.

Thank you for your hard work on this pull request! 😊 While you've made great progress, there are a few critical issues that need to be addressed to meet the core requirements of the task:

  1. Missing getArea() Methods: Each figure class (Circle, Square, RightTriangle, Rectangle, IsoscelesTrapezoid) needs to implement a getArea() method to calculate and return its area. This is essential for fulfilling the task requirements.

  2. Abstract Method in Figure Class: The Figure class should include an abstract method for calculating the area, ensuring that all subclasses implement this method.

  3. getDefaultFigure() Method: The FigureSupplier class should have a getDefaultFigure() method that returns a white circle with a radius of 10, as specified in the task description.

  4. Random Figure Generation: The getRandomFigure() method in FigureSupplier should include logic to generate a Circle, which is currently missing.

These changes are crucial for the functionality and compliance of your code with the task requirements. Once these are addressed, your solution will be much stronger. Keep up the great work, and don't hesitate to reach out if you need any help! 🚀

✨ Please rate this review in the Platform's notification center. I will be grateful for your feedback! ✨

🔄 Fix the issues, commit the changes, and then re-request my review using the Re-request review button in the Reviewers tab.

public void draw() {
System.out.println("Figure: Circle, radius:" + radius + ", color: " + getColor());
}
}

Choose a reason for hiding this comment

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

The Circle class should implement a getArea() method to calculate the area of the circle. According to the task description, all figures should have a method to obtain their area. You can calculate the area of a circle using the formula Math.PI * radius * radius.

public String getColor() {
return color;
}
public abstract void draw();

Choose a reason for hiding this comment

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

The Figure class should include an abstract method for calculating the area, such as public abstract double getArea();. This will ensure that all subclasses implement this method to provide the area calculation.

Random random = new Random();
String color = new ColorSupplier().getRandomColor();

return switch (random.nextInt(6)) {

Choose a reason for hiding this comment

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

The switch statement should include a case for generating a Circle. Currently, the Circle class is missing from the random figure generation.

case 3 -> new Rectangle(color, random.nextDouble() * 10, random.nextDouble() * 10);
default -> new Square(color, random.nextDouble() * 10);
};
}

Choose a reason for hiding this comment

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

You need to implement a getDefaultFigure() method that returns a white circle with a radius of 10, as required by the task description.

public void draw() {
System.out.println("IsoscelesTrapezoid: color = " + getColor() + ", base1 = " + base1 + ", base2 = " + base2 + ", height = " + height);
}
}

Choose a reason for hiding this comment

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

The IsoscelesTrapezoid class should implement a getArea() method to calculate the area of the trapezoid. The formula for the area of an isosceles trapezoid is ((base1 + base2) / 2) * height. Implement this method to comply with the task requirements.

if (i < figures.length / 2) {
figures[i] = figureSupplier.getRandomFigure();
} else {
figures[i] = new Circle("Default Color", 5);

Choose a reason for hiding this comment

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

Instead of creating a Circle with hardcoded values, use the getDefaultFigure() method from FigureSupplier to obtain the default figure. This will ensure that the default figure is consistent with the task requirements.

System.out.println("Figure: Rectangle, width: " + width + ", height: " + height + ", color: " + getColor());

}
}

Choose a reason for hiding this comment

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

The Rectangle class should implement a getArea() method to calculate the area of the rectangle. The formula for the area of a rectangle is width * height. Implement this method to comply with the task requirements.

public void draw() {
System.out.println("RightTriangle: color = " + getColor() + ", firstLeg = " + firstLeg + ", secondLeg = " + secondLeg);
}
}

Choose a reason for hiding this comment

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

The RightTriangle class should implement a getArea() method to calculate the area of the triangle. The formula for the area of a right triangle is (firstLeg * secondLeg) / 2. Implement this method to comply with the task requirements.

System.out.println("Square: color = " + getColor() + ", sideLength = " + sideLength);
}

}

Choose a reason for hiding this comment

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

The Square class should implement a getArea() method to calculate the area of the square. The formula for the area of a square is sideLength * sideLength. Implement this method to comply with the task requirements.

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