Skip to content

Commit

Permalink
added fixes after review
Browse files Browse the repository at this point in the history
  • Loading branch information
Serhiircv committed Nov 27, 2024
1 parent bf474db commit b5dedbb
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 10 deletions.
8 changes: 3 additions & 5 deletions src/main/java/core/basesyntax/Application.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,9 @@ public class Application {
public static void main(String[] args) {

Lottery ball1 = new Lottery();
Lottery ball2 = new Lottery();
Lottery ball3 = new Lottery();

System.out.println(ball1.getRandomBall());
System.out.println(ball2.getRandomBall());
System.out.println(ball3.getRandomBall());
for (int i = 0; i < 3; i++) {
System.out.println(ball1.getRandomBall());
}
}
}
5 changes: 2 additions & 3 deletions src/main/java/core/basesyntax/ColorSupplier.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,9 @@
import java.util.Random;

public class ColorSupplier {
String randomColor = getRandomColor();

public String getRandomColor() {
public Colors getRandomColor() {
int index = new Random().nextInt(Colors.values().length);
return String.valueOf(Colors.values()[index]);
return Colors.values()[index];
}
}
4 changes: 2 additions & 2 deletions src/main/java/core/basesyntax/Lottery.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@

import java.util.Random;

public class Lottery extends ColorSupplier {
public class Lottery {
Random random = new Random();
int randomInt = random.nextInt(100);

public Ball getRandomBall() {
Ball randomBall = new Ball();
randomBall.setColor(randomColor);
randomBall.setColor(randomBall.getColor());
randomBall.setNumber(randomInt);
return randomBall;
}
Expand Down

0 comments on commit b5dedbb

Please sign in to comment.