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

created a program that generate the array with random/default figures #1771

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

Conversation

yaroslav-pryshchepa
Copy link

it also prints information about figures

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 project! 😊 There are a few critical issues that need to be addressed before we can approve the pull request. Specifically, the printInformation methods in the Ellipse and IsoscelesTrapezoid classes are incorrectly labeling the figures, which impacts the clarity and correctness of the output. Additionally, the default case in the FigureSupplier class's switch statement is unnecessary and could be misleading. Once these issues are resolved, your implementation will be in great shape! Keep up the great work, and feel free to reach out if you have any questions.

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

Comment on lines 18 to 19
public String printInformation() {
return "Figure: Rectangle, area: " + getArea()

Choose a reason for hiding this comment

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

The printInformation method incorrectly refers to the figure as a 'Rectangle'. It should be 'Ellipse' to accurately describe the figure type.

case 3 -> new Ellipse(max1, max2);
case 4 -> new Square(max1);
case 5 -> new IsoscelesTrapezoid(max1, max2, max2);
default -> throw new IllegalArgumentException("Unexpected value");

Choose a reason for hiding this comment

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

The default case in the switch statement is unnecessary because the random number generation is controlled by FIRST_MAX_NUMBER and should not exceed this range. Consider removing the default case or handling it in a way that aligns with the expected behavior.

Comment on lines 20 to 21
public String printInformation() {
return "Figure: RightTriangle, area: " + getArea()

Choose a reason for hiding this comment

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

The printInformation method incorrectly refers to the figure as a 'RightTriangle'. It should be 'IsoscelesTrapezoid' to accurately describe the figure type.

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 addressing the previous issues and implementing the required features! 🎉 Your code now meets the task requirements, and all classes are correctly implemented with methods for calculating areas and printing information. The FigureSupplier and ColorSupplier classes are well-designed for generating random figures and colors.

While the code is approved, here are a few points to consider for future improvements:

  1. Ellipse and IsoscelesTrapezoid Classes: You've successfully corrected the printInformation methods to label the figures accurately. Keep up the good work in maintaining clarity in your code.

  2. FigureSupplier Class: Removing the unnecessary default case and handling unexpected values with an IllegalArgumentException is a robust approach. Ensure to maintain such practices for error handling.

  3. Task Requirements and Checklist Compliance: Your code adheres to the task requirements and checklist guidelines, such as avoiding static methods and using constants for magic numbers. This is excellent practice for writing clean and maintainable code.

Remember, the decision to approve is to help you move forward with your learning journey. Please review the comments to further refine your skills and address any critical issues in future projects. Keep learning and improving! 🚀

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

Copy link

@okuzan okuzan left a comment

Choose a reason for hiding this comment

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

Good job overall!

Comment on lines 16 to 19
System.out.println(figures[i].printInformation());
} else {
figures[i] = figureSupplier.getDefaultFigure();
System.out.println(figures[i].printInformation());
Copy link

Choose a reason for hiding this comment

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

extract common part from if-else

case 3 -> new Ellipse(max1, max2);
case 4 -> new Square(max1);
case 5 -> new IsoscelesTrapezoid(max1, max2, max2);
default -> throw new IllegalArgumentException("Unexpected value");
Copy link

Choose a reason for hiding this comment

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

IllegalState is more applicable here, cuz this method doesn't have arguments, problem can only occur via developer's mistake, misconfiguration of lengths. You can also make case 5 default


public abstract class Figure implements FigureSquare, FigureInformation {
private String color;

Copy link

Choose a reason for hiding this comment

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

consider creating a constructor for color and calling super() in subclasses

Copy link

@sarakhmen sarakhmen left a comment

Choose a reason for hiding this comment

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

lgtm!

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.

4 participants