Skip to content

Commit f73e899

Browse files
committed
added changes after review
1 parent cab434a commit f73e899

File tree

4 files changed

+11
-14
lines changed

4 files changed

+11
-14
lines changed

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

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,9 @@ public class Application {
44
public static void main(String[] args) {
55
Lottery lottery = new Lottery();
66

7-
Ball ball1 = lottery.getRandomBall();
8-
Ball ball2 = lottery.getRandomBall();
9-
Ball ball3 = lottery.getRandomBall();
10-
11-
System.out.println(ball1);
12-
System.out.println(ball2);
13-
System.out.println(ball3);
7+
for (int i = 0; i < 3; i++) {
8+
Ball ball = lottery.getRandomBall();
9+
System.out.println(ball);
10+
}
1411
}
1512
}

src/main/java/core/basesyntax/Ball.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
package core.basesyntax;
22

33
public class Ball {
4-
private Color color;
4+
private String color;
55
private int number;
66

7-
public Ball(Color color, int number) {
7+
public Ball(String color, int number) {
88
this.color = color;
99
this.number = number;
1010
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
public class ColorSupplier {
66
private Random random = new Random();
77

8-
public Color getRandomColor() {
8+
public String getRandomColor() {
99
int index = random.nextInt(Color.values().length);
10-
return Color.values()[index];
10+
return Color.values()[index].name();
1111
}
1212
}

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@
33
import java.util.Random;
44

55
public class Lottery {
6+
private static final int MAX_NUMBER =100;
67
private Random random = new Random();
78
private ColorSupplier colorSupplier = new ColorSupplier();
89

910
public Ball getRandomBall() {
10-
Color color = colorSupplier.getRandomColor();
11-
int number = random.nextInt(100) + 1;
11+
String color = colorSupplier.getRandomColor();
12+
int number = random.nextInt(MAX_NUMBER) + 1;
1213
return new Ball(color, number);
1314
}
14-
1515
}

0 commit comments

Comments
 (0)