Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion src/main/java/core/basesyntax/Application.java
Original file line number Diff line number Diff line change
Expand Up @@ -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.

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.


for (int i = 0; i < balls.length; i++) {
balls[i] = lottery.getRandomBall();
}

for (Ball ball: balls) {
System.out.println(ball.toString());
}
}
}
17 changes: 17 additions & 0 deletions src/main/java/core/basesyntax/Ball.java
Original file line number Diff line number Diff line change
@@ -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.

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.

private final int number;

public Ball(String color, int number) {
this.color = color;
this.number = number;
}

@Override
public String toString() {
return this.color + " " + "ball" + " "
+ "with number" + " " + this.number;
}
}
9 changes: 9 additions & 0 deletions src/main/java/core/basesyntax/Color.java
Original file line number Diff line number Diff line change
@@ -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 enum Color {
RED,
BLUE,
GREEN,
WHITE,
BLACK
}
6 changes: 5 additions & 1 deletion src/main/java/core/basesyntax/ColorSupplier.java
Original file line number Diff line number Diff line change
@@ -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.

import java.util.Random;

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.

return null;
return Color.values()[this.random.nextInt(Color.values().length)].name();
}
}
17 changes: 17 additions & 0 deletions src/main/java/core/basesyntax/Lottery.java
Original file line number Diff line number Diff line change
@@ -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.

import java.util.Random;

public class Lottery {
private static final int MAX_BALL_NUMBER = 100;

private final Random random = new Random();
private final ColorSupplier colorSupplier = new ColorSupplier();

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.

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.

);
}
}