Skip to content

2#2013

Open
VadimN637 wants to merge 1 commit intomate-academy:masterfrom
VadimN637:master
Open

2#2013
VadimN637 wants to merge 1 commit intomate-academy:masterfrom
VadimN637:master

Conversation

@VadimN637
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.

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

  1. Rate AI review example

package core.basesyntax;

import java.util.Random;

Choose a reason for hiding this comment

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

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
}

Choose a reason for hiding this comment

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

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();

Choose a reason for hiding this comment

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

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++) {

Choose a reason for hiding this comment

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

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.

Comment on lines +11 to +13
int number = random.nextInt(MAX_NUMBER) + 1; // 1..100
String color = colorSupplier.getRandomColor();
return new Ball(color, number);

Choose a reason for hiding this comment

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

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.

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