Conversation
mateacademy-ai-mentor
left a comment
There was a problem hiding this comment.
Review Summary
Your solution meets the functional requirements: Ball, ColorSupplier, Lottery, and Application all work together correctly to generate and print three random balls, and the use of Random, enums, and toString() is appropriate and correct. The remaining issues are minor style/checklist points rather than blockers: there are a few redundant empty lines in ColorSupplier.java (right after the package/imports, after the enum, and after the random field), which you should remove to keep formatting clean [CHECKLIST ITEM #1]. In Application.java, the loop uses a magic number 3; it would be better to introduce a constant like private static final int BALL_COUNT = 3; and use it in the for condition [CHECKLIST ITEM #9]. In Lottery.java, you can simplify getRandomBall() by returning the new Ball(...) directly instead of first storing color and number in temporary local variables [CHECKLIST ITEM #2]. None of these affect correctness, so your work is accepted, but I recommend applying these small improvements to align fully with the checklist and strengthen your coding style.
✨ Please rate this review in the Platform's notification center1. I will be grateful for your feedback! ✨
Footnotes
| package core.basesyntax; | ||
|
|
||
| import java.util.Random; | ||
|
|
There was a problem hiding this comment.
This file has a redundant empty line after the package declaration/imports. This violates checklist item #1: "Please don't add redundant empty lines to your code (e.g., after class declaration or method signature)." Remove the unnecessary blank line here.
| BLACK, | ||
| BLUE | ||
| } | ||
|
|
There was a problem hiding this comment.
There is a redundant empty line after the enum closing }. This violates checklist item #1: "Please don't add redundant empty lines to your code (e.g., after class declaration or method signature)." Remove the blank line to keep the file compact.
| } | ||
|
|
||
| private final Random random = new Random(); | ||
|
|
There was a problem hiding this comment.
There is a redundant empty line after the random field declaration. This violates checklist item #1: "Please don't add redundant empty lines to your code (e.g., after class declaration or method signature)." Removing this blank line will satisfy the checklist requirement.
| public static void main(String[] args) { | ||
| // create three balls using class Lottery and print information about them in console | ||
| Lottery lottery = new Lottery(); | ||
| for (int i = 0; i < 3; i++) { |
There was a problem hiding this comment.
This violates checklist item #9: "All magic numbers in your code should be constants." Declare a constant like private static final int BALL_COUNT = 3; in the Application class and use i < BALL_COUNT in the loop instead of the literal 3.
| int number = random.nextInt(MAX_NUMBER) + 1; // 1..100 | ||
| String color = colorSupplier.getRandomColor(); | ||
| return new Ball(color, number); |
There was a problem hiding this comment.
This creates temporary local variables (number and color) even though you can return the constructed Ball directly. This violates checklist item #2: "Don't create temporary variables if you can directly return value from the method". Consider returning new Ball(colorSupplier.getRandomColor(), random.nextInt(MAX_NUMBER) + 1); to avoid unnecessary locals.
No description provided.