File tree Expand file tree Collapse file tree 6 files changed +30
-14
lines changed
src/main/java/hexlet/code/games Expand file tree Collapse file tree 6 files changed +30
-14
lines changed Original file line number Diff line number Diff line change @@ -24,14 +24,14 @@ dependencies {
2424
2525tasks.test {
2626 useJUnitPlatform()
27- finalizedBy(" jacocoTestReport" ) // Ссылаемся на задачу по имени, чтобы она выполнялась после тестов
27+ finalizedBy(" jacocoTestReport" )
2828}
2929
3030tasks.named<JacocoReport >(" jacocoTestReport" ) {
31- dependsOn(tasks.test) // Задаем зависимость от задачи тестирования
31+ dependsOn(tasks.test)
3232 reports {
33- xml.required.set(true ) // Генерация XML отчета
34- html.required.set(true ) // Генерация HTML отчета
33+ xml.required.set(true )
34+ html.required.set(true )
3535 }
3636}
3737
Original file line number Diff line number Diff line change 1010public class Calc {
1111 public static int calc () {
1212
13+ final int maxRandomNumber1 = 19 ;
14+ final int maxRandomNumber2 = 9 ;
15+
1316 Random random = new Random ();
1417 String mainGameQuestion = "What is the result of the expression?" ;
1518
1619 String [] question = new String [Engine .ROUNDS ];
1720 String [] correctAnswer = new String [Engine .ROUNDS ];
1821
1922 for (var i = 0 ; i < Engine .ROUNDS ; i ++) {
20- int randomNumber1 = random .nextInt (19 ) + 1 ;
21- int randomNumber2 = random .nextInt (9 ) + 1 ;
23+ int randomNumber1 = random .nextInt (maxRandomNumber1 ) + 1 ;
24+ int randomNumber2 = random .nextInt (maxRandomNumber2 ) + 1 ;
2225
2326 String plus = randomNumber1 + " + " + randomNumber2 ;
2427 String minus = randomNumber1 + " - " + randomNumber2 ;
Original file line number Diff line number Diff line change 77public class Even {
88 public static int even () {
99
10+ final int maxRandomNumber = 5 ;
11+
1012 Random random = new Random ();
1113 String mainGameQuestion = "Answer 'yes' if the number is even, otherwise answer 'no'." ;
1214
1315 String [] question = new String [Engine .ROUNDS ];
1416 String [] correctAnswer = new String [Engine .ROUNDS ];
1517
1618 for (var i = 0 ; i < Engine .ROUNDS ; i ++) {
17- int randomNumber = random .nextInt (99 ) + 1 ;
19+ int randomNumber = random .nextInt (maxRandomNumber ) + 1 ;
1820 question [i ] = Integer .toString (randomNumber );
1921 correctAnswer [i ] = (randomNumber % 2 == 0 ) ? "yes" : "no" ;
2022 }
Original file line number Diff line number Diff line change 88
99public class Gcd {
1010 public static int gcd () {
11+
12+ final int maxrandomCommon = 10 ;
13+ final int maxRandomNumber = 10 ;
14+
1115 Random random = new Random ();
1216 String mainGameQuestion = "Find the greatest common divisor of given numbers." ;
1317
@@ -16,9 +20,9 @@ public static int gcd() {
1620
1721 for (var i = 0 ; i < Engine .ROUNDS ; i ++) {
1822
19- int randomCommon = random .nextInt (10 ) + 2 ;
20- int randomNumber1 = randomCommon * (random .nextInt (10 ) + 1 );
21- int randomNumber2 = randomCommon * (random .nextInt (10 ) + 1 );
23+ int randomCommon = random .nextInt (maxrandomCommon ) + 2 ;
24+ int randomNumber1 = randomCommon * (random .nextInt (maxRandomNumber ) + 1 );
25+ int randomNumber2 = randomCommon * (random .nextInt (maxRandomNumber ) + 1 );
2226
2327 BigInteger bigA = BigInteger .valueOf (randomNumber1 );
2428 BigInteger bigB = BigInteger .valueOf (randomNumber2 );
Original file line number Diff line number Diff line change 77public class Prime {
88 public static int prime () {
99
10+ final int maxRandomNumber = 20 ;
11+
1012 Random random = new Random ();
1113 String mainGameQuestion = "Answer 'yes' if given number is prime. Otherwise answer 'no'." ;
1214
1315 String [] question = new String [Engine .ROUNDS ];
1416 String [] correctAnswer = new String [Engine .ROUNDS ];
1517
1618 for (var i = 0 ; i < Engine .ROUNDS ; i ++) {
17- int randomNumber = random .nextInt (20 ) + 2 ;
19+ int randomNumber = random .nextInt (maxRandomNumber ) + 2 ;
1820 question [i ] = Integer .toString (randomNumber );
1921
2022 boolean isPrime = true ;
Original file line number Diff line number Diff line change 77
88public class Progression {
99 public static int progression () {
10+
11+ final int minArrayLength = 5 ;
12+ final int maxStep = 9 ;
13+ final int maxStartValue = 14 ;
14+
1015 Random random = new Random ();
1116 String mainGameQuestion = "What number is missing in the progression?" ;
1217
@@ -15,11 +20,11 @@ public static int progression() {
1520
1621 for (var i = 0 ; i < Engine .ROUNDS ; i ++) {
1722
18- int arrayLength = random .nextInt (5 ) + 5 ;
23+ int arrayLength = random .nextInt (minArrayLength ) + minArrayLength ;
1924 int [] array = new int [arrayLength ];
2025
21- int step = random .nextInt (9 ) + 1 ;
22- int start = random .nextInt (14 ) + 1 ;
26+ int step = random .nextInt (maxStep ) + 1 ;
27+ int start = random .nextInt (maxStartValue ) + 1 ;
2328
2429 for (int j = 0 ; j < arrayLength ; j ++) {
2530 array [j ] = start + j * step ;
You can’t perform that action at this time.
0 commit comments