11package hexlet .code .games ;
22
3+ import java .util .Random ;
4+
5+
36public final class Progression {
4- private static int numberOne ;
57 private static int numberTwo ;
68 private static int sumOfNumbers ;
79 private static int progressionLength ;
8- private static int maxValue = 20 ;
9- private static int minValue = 7 ;
1010 private static int numberToSkip ;
11- private static StringBuilder progressionString = new StringBuilder ();
12- private static int correctAnswer ;
1311
1412 private Progression () {
1513 throw new AssertionError ("Utility class instantiation prohibited" );
@@ -20,16 +18,20 @@ public static void startGameProgression() {
2018 }
2119
2220 public static String generateCorrectAnswer () {
23- numberOne = (int ) (Math .random ()*100 );
24- numberTwo = (int ) (Math .random ()*100 );
21+ Random random = new Random ();
22+ int maxValue = 20 ;
23+ int minValue = 7 ;
24+ int numberOne = random .nextInt (100 );
25+ numberTwo = random .nextInt (100 );
2526 sumOfNumbers = numberOne ;
26- progressionLength = ( int ) ( Math . random ()*( maxValue - minValue + 1 ) + minValue ) ;
27- numberToSkip = ( int ) ( Math . random ()* progressionLength );
28- correctAnswer = numberOne + numberTwo * numberToSkip ;
27+ progressionLength = random . nextInt ( maxValue - minValue + 1 ) + minValue ;
28+ numberToSkip = random . nextInt ( progressionLength );
29+ int correctAnswer = numberOne + numberTwo * numberToSkip ;
2930 return String .valueOf (correctAnswer );
3031 }
3132
3233 public static void generateProgression () {
34+ StringBuilder progressionString = new StringBuilder ();
3335 progressionString .setLength (0 );
3436 progressionString .append ("Question: " );
3537 for (int i = 0 ; i < progressionLength ; i ++) {
0 commit comments