Skip to content

Conversation

FranticSkipper
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

Thank you for your submission! You're on the right track with your class structure and use of enums, but there are a few critical issues that must be fixed before your code meets all the requirements:

  1. Use of String instead of Color enum

    • The Ball class should use the Color enum for its color field and constructor parameter, not a String. This ensures type safety and matches the assignment requirements.
    • The ColorSupplier.getRandomColor() method should return a Color value, not a String. Update its return type and logic accordingly.
    • Update the Lottery.getRandomBall() method to use the enum type throughout (pass the Color to Ball).
  2. Magic Numbers Not Defined as Constants

    • In Application.java, the number 3 (used for the array size and loop) should be defined as a constant, e.g., private static final int BALLS_COUNT = 3;, following Java constant naming conventions.
  3. Possible Incorrect Ball Number Range

    • In Lottery.java, the random number generation currently allows numbers from 0 to 100 inclusive. If the intended range is 1-100, you should use random.nextInt(MAX_BALL_NUMBER) + 1 to ensure numbers are between 1 and 100.
  4. Redundant Empty Lines After Class Declarations

    • There are unnecessary empty lines after class declarations in several files (Application.java, Ball.java, Color.java, ColorSupplier.java, Lottery.java). Please remove these to comply with the style requirements.

Next Steps:

  • Update your code to use the Color enum everywhere a color is needed.
  • Replace all magic numbers with properly named constants.
  • Adjust the random number logic if needed.
  • Clean up redundant empty lines.

Once you've made these changes, your code will be much more robust and fully compliant with the assignment requirements. Keep up the good work—you're almost there!


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

Important

Fix the issues, commit the changes, and then re-request my review using the Re-request review button2 in the Reviewers tab.

Tip

If you have any comments about this review, please leave a message in the Add a comment section below and mention me with the @mateacademy-ai-mentor tag3.
I will read your message during my next review of your pull request. Please do not reply directly to my comments, as that feature is not supported yet.

Caution

Do not close the pull request until the review is complete. Closing it early can lead to unexpected behavior and disrupt the review process.

Footnotes

  1. Rate AI review example

  2. Re-request AI review example

  3. Add AI review comments example

@@ -2,6 +2,15 @@

public class Application {
public static void main(String[] args) {
// create three balls using class Lottery and print information about them in console
Lottery lottery = new Lottery();
Ball[] balls = new Ball[3];

Choose a reason for hiding this comment

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

This violates checklist item: "All magic numbers (like 100, 3) must be defined as constants, following Java constant naming conventions." You should define a constant (e.g., private static final int BALLS_COUNT = 3;) and use it here instead of the literal 3.

@@ -2,6 +2,15 @@

Choose a reason for hiding this comment

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

This violates checklist item: "Avoid redundant empty lines after class declarations or method signatures." There is an unnecessary empty line after the class declaration.

package core.basesyntax;

public class Ball {
private final String color;

Choose a reason for hiding this comment

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

This violates the requirement: "Create a Ball class with fields: color and number." and "Create an enum with different colors." The color field should be of the enum type (e.g., Color), not String. The constructor should also accept the enum type, not a String.

@@ -0,0 +1,17 @@
package core.basesyntax;

Choose a reason for hiding this comment

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

This violates checklist item: "Avoid redundant empty lines after class declarations or method signatures." There is an unnecessary empty line after the class declaration.

@@ -0,0 +1,9 @@
package core.basesyntax;

Choose a reason for hiding this comment

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

This violates checklist item: "Avoid redundant empty lines after class declarations or method signatures." There is an unnecessary empty line after the package declaration.

public class ColorSupplier {
private final Random random = new Random();

public String getRandomColor() {

Choose a reason for hiding this comment

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

This violates the requirement: "Implement a ColorSupplier class with a getRandomColor() method that returns a random color from the enum using the Random class." The method should return the Color enum type, not a String. Change the return type to Color and return the enum value directly.

@@ -1,7 +1,11 @@
package core.basesyntax;

Choose a reason for hiding this comment

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

This violates checklist item: "Avoid redundant empty lines after class declarations or method signatures." There is an unnecessary empty line after the class declaration.


public Ball getRandomBall() {
return new Ball(
this.colorSupplier.getRandomColor(),

Choose a reason for hiding this comment

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

This violates the requirement: "The Ball class must have a constructor that sets both color and number." and "Create an enum with different colors." The Ball constructor should accept the Color enum, not a String. Ensure that getRandomColor() returns Color and Ball accepts Color as its color field.

public Ball getRandomBall() {
return new Ball(
this.colorSupplier.getRandomColor(),
this.random.nextInt(MAX_BALL_NUMBER + 1)

Choose a reason for hiding this comment

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

This may violate the requirement: "The maximum possible number for the ball is 100 (i.e., numbers should be in the range 0 to 99 or 1 to 100, clarify in implementation)." If the intended range is 1-100, you should use random.nextInt(MAX_BALL_NUMBER) + 1 instead of random.nextInt(MAX_BALL_NUMBER + 1). Please clarify and adjust accordingly.

@@ -0,0 +1,17 @@
package core.basesyntax;

Choose a reason for hiding this comment

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

This violates checklist item: "Avoid redundant empty lines after class declarations or method signatures." There is an unnecessary empty line after the class declaration.

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

All core requirements for the lottery application are fully met. Your code correctly implements the required classes (Ball, Color, ColorSupplier, Lottery, and Application), uses enums and constants appropriately, and follows Java conventions and best practices. There are no critical or blocking issues—everything functions as expected, and your code is clean and well-structured. Excellent job! Keep up the great work.


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

Footnotes

  1. Rate AI review example

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.

3 participants