Skip to content

Commit e6ed20c

Browse files
committed
fix mistakes with random
1 parent ef33372 commit e6ed20c

File tree

6 files changed

+7
-10
lines changed

6 files changed

+7
-10
lines changed

app/src/main/java/hexlet/code/Engine.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package hexlet.code;
22

33
import java.util.Scanner;
4+
import java.util.Random;
45

56
import hexlet.code.games.Calc;
67
import hexlet.code.games.Even;
@@ -9,6 +10,7 @@
910
import hexlet.code.games.Progression;
1011

1112
public final class Engine {
13+
public static final Random random = new Random();
1214
private static int scoreCounter = 0;
1315
private static int scoreToWin = 3;
1416
private static StringBuilder correctAnswer = new StringBuilder();

app/src/main/java/hexlet/code/games/Calc.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package hexlet.code.games;
22

3-
import java.util.Random;
3+
import static hexlet.code.Engine.random;
44

55
public final class Calc {
66

@@ -14,7 +14,6 @@ public static void startGameCalc() {
1414
}
1515

1616
public static String generateCorrectAnswer() {
17-
Random random = new Random();
1817
int correctAnswer;
1918
int numberOne = random.nextInt(100);
2019
int numberTwo = random.nextInt(100);

app/src/main/java/hexlet/code/games/Even.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package hexlet.code.games;
22

3-
import java.util.Random;
3+
import static hexlet.code.Engine.random;
44

55
public final class Even {
66

@@ -14,7 +14,6 @@ public static void startGameEven() {
1414

1515

1616
public static String generateCorrectAnswer() {
17-
Random random = new Random();
1817
StringBuilder correctAnswer = new StringBuilder();
1918
final int evenDivisor = 2;
2019
final int oddRemainder = 1;

app/src/main/java/hexlet/code/games/GCD.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package hexlet.code.games;
22

3-
import java.util.Random;
3+
import static hexlet.code.Engine.random;
44

55
public final class GCD {
66

@@ -13,7 +13,6 @@ public static void startGameGCD() {
1313
}
1414

1515
public static String generateCorrectAnswer() {
16-
Random random = new Random();
1716
int numberA = random.nextInt(100);
1817
int numberB = random.nextInt(100);
1918
int numberC;

app/src/main/java/hexlet/code/games/Prime.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package hexlet.code.games;
22

3-
import java.util.Random;
3+
import static hexlet.code.Engine.random;;
44

55
public final class Prime {
66
private Prime() {
@@ -12,7 +12,6 @@ public static void startGamePrime() {
1212
}
1313

1414
public static String generateCorrectAnswer() {
15-
Random random = new Random();
1615
int number = random.nextInt(100);
1716
int maxValue = (int) (Math.ceil(Math.sqrt(number)));
1817
final int MIN_VALUE = 3;

app/src/main/java/hexlet/code/games/Progression.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package hexlet.code.games;
22

3-
import java.util.Random;
3+
import static hexlet.code.Engine.random;
44

55

66
public final class Progression {
@@ -18,7 +18,6 @@ public static void startGameProgression() {
1818
}
1919

2020
public static String generateCorrectAnswer() {
21-
Random random = new Random();
2221
int maxValue = 20;
2322
int minValue = 7;
2423
int numberOne = random.nextInt(100);

0 commit comments

Comments
 (0)