Skip to content

Commit 239ab73

Browse files
committed
Added fixed after review.
1 parent c3479ac commit 239ab73

File tree

3 files changed

+13
-10
lines changed

3 files changed

+13
-10
lines changed

src/main/java/core/basesyntax/Application.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,10 @@
33
public class Application {
44
public static void main(String[] args) {
55
Lottery lottery = new Lottery();
6-
lottery.getRandomBall();
7-
lottery.getRandomBall();
8-
lottery.getRandomBall();
6+
Ball ball = new Ball();
7+
int ballsQuantity = 3;
8+
for (int i = 0; i < ballsQuantity; i++) {
9+
lottery.getRandomBall(ball);
10+
}
911
}
1012
}

src/main/java/core/basesyntax/ColorSupplier.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
public class ColorSupplier {
66

7-
public String getRandomColor() {
7+
public static String getRandomColor() {
88
int index = new Random().nextInt(Colors.values().length);
99
String randomColor = String.valueOf(Colors.values()[index]);
1010
return randomColor;

src/main/java/core/basesyntax/Lottery.java

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,13 @@
22

33
import java.util.Random;
44

5-
public class Lottery extends Ball {
5+
public class Lottery {
66

7-
public void getRandomBall() {
8-
ColorSupplier colorSupplier = new ColorSupplier();
9-
setNumber(new Random().nextInt(100));
10-
setColor(colorSupplier.getRandomColor());
11-
System.out.println("The ball with number " + getNumber() + " is " + getColor());
7+
public Ball getRandomBall(Ball ball) {
8+
int maxNumber = 100;
9+
ball.setNumber(new Random().nextInt(maxNumber));
10+
ball.setColor(ColorSupplier.getRandomColor());
11+
System.out.println("The ball with number " + ball.getNumber() + " is " + ball.getColor());
12+
return ball;
1213
}
1314
}

0 commit comments

Comments
 (0)