File tree Expand file tree Collapse file tree 2 files changed +7
-3
lines changed
app/src/main/java/hexlet/code/games Expand file tree Collapse file tree 2 files changed +7
-3
lines changed Original file line number Diff line number Diff line change 11package hexlet .code .games ;
22
33import hexlet .code .Engine ;
4+ import hexlet .code .Utils ;
45
56public class GCD {
67
78 private static final String RULES = "Find the greatest common divisor of given numbers." ;
89 private static final int MAX_NUMBER = 100 ;
10+ private static final int MIN_NUMBER = 1 ;
911
1012 public static void gameGCD () {
1113 String [][] questionsAndAnswers = generateData ();
@@ -16,8 +18,8 @@ public static String[][] generateData() {
1618 String [][] questionsAndAnswers = new String [Engine .ROUNDS ][2 ];
1719
1820 for (int i = 0 ; i < Engine .ROUNDS ; i ++) {
19- int firstNumber = ( int ) ( Math . random () * MAX_NUMBER );
20- int secondNumber = ( int ) ( Math . random () * MAX_NUMBER );
21+ int firstNumber = Utils . getRandomInt ( MIN_NUMBER , MAX_NUMBER );
22+ int secondNumber = Utils . getRandomInt ( MIN_NUMBER , MAX_NUMBER );
2123 String question = firstNumber + " " + secondNumber ;
2224
2325 int gcd = calculateGCD (firstNumber , secondNumber );
Original file line number Diff line number Diff line change 11package hexlet .code .games ;
22
33import hexlet .code .Engine ;
4+ import hexlet .code .Utils ;
45
56public class Prime {
67
78 private static final String RULES = "Answer 'yes' if given number is prime. Otherwise answer 'no'." ;
89 private static final int MAX_NUMBER = 100 ;
10+ private static final int MIN_NUMBER = 1 ;
911
1012 public static void gamePrime () {
1113 String [][] questionsAndAnswers = generateData ();
@@ -16,7 +18,7 @@ public static String[][] generateData() {
1618 String [][] questionsAndAnswers = new String [Engine .ROUNDS ][2 ];
1719
1820 for (int i = 0 ; i < Engine .ROUNDS ; i ++) {
19- int number = ( int ) ( Math . random () * MAX_NUMBER );
21+ int number = Utils . getRandomInt ( MIN_NUMBER , MAX_NUMBER );
2022 questionsAndAnswers [i ][0 ] = Integer .toString (number );
2123 if (isPrime (number )) {
2224 questionsAndAnswers [i ][1 ] = "yes" ;
You can’t perform that action at this time.
0 commit comments