diff --git a/src/main/java/core/basesyntax/Ball.java b/src/main/java/core/basesyntax/Ball.java index ff68f5fa8..119819628 100644 --- a/src/main/java/core/basesyntax/Ball.java +++ b/src/main/java/core/basesyntax/Ball.java @@ -2,14 +2,14 @@ public class Ball { - private String color; + private Colors color; private int number; - public void setColor(String color) { + public void setColor(Colors color) { this.color = color; } - public String getColor() { + public Colors getColor() { return color; } diff --git a/src/main/java/core/basesyntax/Lottery.java b/src/main/java/core/basesyntax/Lottery.java index ea4e3c086..50e7d27bf 100644 --- a/src/main/java/core/basesyntax/Lottery.java +++ b/src/main/java/core/basesyntax/Lottery.java @@ -3,13 +3,18 @@ import java.util.Random; public class Lottery { - Random random = new Random(); - int randomInt = random.nextInt(100); + ColorSupplier supplier = new ColorSupplier(); + + public int getRandomInt() { + Random random = new Random(); + int randomInt = random.nextInt(100); + return randomInt; + } public Ball getRandomBall() { Ball randomBall = new Ball(); - randomBall.setColor(randomBall.getColor()); - randomBall.setNumber(randomInt); + randomBall.setColor(supplier.getRandomColor()); + randomBall.setNumber(getRandomInt()); return randomBall; } }