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
23 changes: 23 additions & 0 deletions src/main/java/core/basesyntax/Ball.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package core.basesyntax;

public class Ball {

private String color;
private int number;

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

@Override
public String toString() {
return "Ball{"
+
"color=" + color
+
", number=" + number
+
'}';
}
}
7 changes: 7 additions & 0 deletions src/main/java/core/basesyntax/Color.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package core.basesyntax;

public enum Color {
RED,
GREEN,
BLUE
}
5 changes: 4 additions & 1 deletion src/main/java/core/basesyntax/ColorSupplier.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
package core.basesyntax;

import java.util.Random;

public class ColorSupplier {

public String getRandomColor() {
return null;
return Color.values()[new Random().nextInt(0, Color.values().length)].name();
Copy link

Choose a reason for hiding this comment

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

please make random object as a class member

}
}
10 changes: 10 additions & 0 deletions src/main/java/core/basesyntax/Lottery.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package core.basesyntax;

import java.util.Random;

public class Lottery {

public Ball getRandomBall() {
return new Ball(new ColorSupplier().getRandomColor(), new Random().nextInt(0, 100));
Copy link

Choose a reason for hiding this comment

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

please make ColorSupplier and Random object as a class members.
please do not use magic number, and think about upper number (maybe 101?)

}
}
Loading