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

Implement tasks #1760

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

Implement tasks #1760

wants to merge 15 commits into from

Conversation

euulu
Copy link

@euulu euulu commented Dec 11, 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.

Thank you for your hard work on this pull request! 😊 While your implementation is mostly on the right track, there are a few critical issues that need to be addressed to meet the core requirements of the task:

  1. Static Methods Usage: The use of static methods in FigureSupplier and ColorSupplier for getRandomFigure, getDefaultFigure, and getRandomColor is against the checklist requirements. These should be instance methods, and you should create an instance of FigureSupplier outside the loop in Application.java.

  2. Magic Numbers: There are magic numbers in your code, particularly in FigureSupplier. These should be replaced with named constants to improve code readability and maintainability.

  3. Enum String Representation: Ensure that you use name() instead of toString() for enum constants to align with best practices.

Addressing these issues will not only align your code with the task requirements but also enhance its quality and maintainability. Keep up the great work, and feel free to reach out if you have any questions or need further guidance! 🚀

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

Figure[] figures = new Figure[6];
int halfSize = figures.length / 2;
for (int i = 0; i < halfSize; i++) {
figures[i] = FigureSupplier.getRandomFigure();

Choose a reason for hiding this comment

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

Avoid using static methods for getRandomFigure and getDefaultFigure. Instead, create an instance of FigureSupplier and call these methods on that instance. This aligns with the checklist item: 'Don't use static methods in your solution'.

int halfSize = figures.length / 2;
for (int i = 0; i < halfSize; i++) {
figures[i] = FigureSupplier.getRandomFigure();
figures[halfSize + i] = FigureSupplier.getDefaultFigure();

Choose a reason for hiding this comment

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

Similarly, avoid using static methods for getDefaultFigure. Create an instance of FigureSupplier before the loop and use it to call getDefaultFigure. This aligns with the checklist item: 'You should create several random Figures, so you will use a loop. Please don't create a new FigureSupplier() inside the loop.'

import java.util.Random;

public class ColorSupplier {
public static String getRandomColor() {

Choose a reason for hiding this comment

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

Avoid using a static method for getRandomColor. Convert this method to an instance method by removing the static keyword. This aligns with the checklist item: 'Don't use static methods in your solution'.

import java.util.Random;

public class FigureSupplier {
public static Figure getRandomFigure() {

Choose a reason for hiding this comment

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

Avoid using a static method for getRandomFigure. Convert this method to an instance method by removing the static keyword. This aligns with the checklist item: 'Don't use static methods in your solution'.

return randomFigure;
}

public static Figure getDefaultFigure() {

Choose a reason for hiding this comment

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

Avoid using a static method for getDefaultFigure. Convert this method to an instance method by removing the static keyword. This aligns with the checklist item: 'Don't use static methods in your solution'.

@euulu
Copy link
Author

euulu commented Dec 11, 2024

  1. Enum String Representation: Ensure that you use name() instead of toString() for enum constants to align with best practices.

Can you please explain in detailsthis point from your review. Where exactly should i use name() method instead of toString()?

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 solution! 🎉 Your code meets the task requirements, and you've made significant improvements based on the feedback. Here are some key points to consider for further enhancement:

  1. Magic Numbers: You've addressed the issue of magic numbers by using constants for default values in FigureSupplier. However, remember to replace the number 6 used for the array size and the RGB values in DEFAULT_COLOR with named constants to improve readability and maintainability.

  2. Static Methods: You've correctly avoided static methods by creating instances of FigureSupplier and ColorSupplier. This aligns well with the task requirements.

  3. Area Calculation: Ensure the formula for calculating the area of an isosceles trapezoid is correct. The correct formula is ((bottom + top) / 2) * height, where height can be calculated using the Pythagorean theorem.

  4. Random Values: Consider setting a realistic range for random values to ensure meaningful figures are generated.

Your efforts to address the feedback are commendable, and the decision to approve the pull request is to help you move forward with your learning. Please review the comments to further improve your code. Keep up the great work, and continue to learn from these experiences! 🚀

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

public static void main(String[] args) {
ColorSupplier colorSupplier = new ColorSupplier();
FigureSupplier figureSupplier = new FigureSupplier(colorSupplier);
Figure[] figures = new Figure[6];

Choose a reason for hiding this comment

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

Consider replacing the magic number 6 with a named constant to improve code readability and maintainability. This aligns with the checklist requirement to avoid magic numbers in your code.


public class FigureSupplier {
public static final String DEFAULT_COLOR = "rgb(255, 255, 255)";
public static final double DEFAULT_RADIUS = 10.0;

Choose a reason for hiding this comment

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

Consider replacing the magic number 10.0 with a named constant to improve code readability and maintainability. This aligns with the checklist requirement to avoid magic numbers in your code.

import java.util.Random;

public class FigureSupplier {
public static final String DEFAULT_COLOR = "rgb(255, 255, 255)";

Choose a reason for hiding this comment

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

Consider replacing the RGB values in DEFAULT_COLOR with named constants to improve code readability and maintainability.

Comment on lines +21 to +29
double squareSide = random.nextDouble();
double width = random.nextDouble();
double height = random.nextDouble();
double firstLeg = random.nextDouble();
double secondLeg = random.nextDouble();
double radius = random.nextDouble();
double bottom = random.nextDouble();
double top = random.nextDouble();
double trapSide = random.nextDouble();

Choose a reason for hiding this comment

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

The random values for dimensions should be within a realistic range to ensure meaningful figures are generated. Consider setting a minimum and maximum value for these random numbers.

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