-
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
Implement tasks #1760
base: master
Are you sure you want to change the base?
Implement tasks #1760
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.
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:
-
Static Methods Usage: The use of static methods in
FigureSupplier
andColorSupplier
forgetRandomFigure
,getDefaultFigure
, andgetRandomColor
is against the checklist requirements. These should be instance methods, and you should create an instance ofFigureSupplier
outside the loop inApplication.java
. -
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. -
Enum String Representation: Ensure that you use
name()
instead oftoString()
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(); |
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.
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(); |
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.
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() { |
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.
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() { |
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.
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() { |
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.
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'.
Can you please explain in detailsthis point from your review. Where exactly should i use |
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 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:
-
Magic Numbers: You've addressed the issue of magic numbers by using constants for default values in
FigureSupplier
. However, remember to replace the number6
used for the array size and the RGB values inDEFAULT_COLOR
with named constants to improve readability and maintainability. -
Static Methods: You've correctly avoided static methods by creating instances of
FigureSupplier
andColorSupplier
. This aligns well with the task requirements. -
Area Calculation: Ensure the formula for calculating the area of an isosceles trapezoid is correct. The correct formula is
((bottom + top) / 2) * height
, whereheight
can be calculated using the Pythagorean theorem. -
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]; |
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 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; |
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 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)"; |
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 replacing the RGB values in DEFAULT_COLOR
with named constants to improve code readability and maintainability.
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(); |
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 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.
No description provided.