Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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
13 changes: 12 additions & 1 deletion src/main/java/core/basesyntax/Application.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,18 @@
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 Application {
private static final int BALL_COUNT = 3;

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[BALL_COUNT];

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 Color color;
private final int number;

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

@Override
public String toString() {
return this.color.name() + " " + "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
}
8 changes: 6 additions & 2 deletions 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 {
public String getRandomColor() {
return null;
private final Random random = new Random();

public Color getRandomColor() {
return Color.values()[this.random.nextInt(Color.values().length)];
}
}
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
);
}
}