Skip to content

Commit 46fdaa6

Browse files
author
MouserRU
committed
refractoring #1
1 parent 840b5ec commit 46fdaa6

1 file changed

Lines changed: 25 additions & 0 deletions

File tree

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
package hexlet.code;
2+
3+
import java.security.SecureRandom;
4+
5+
public class Utils {
6+
private static final SecureRandom RND = new SecureRandom();
7+
8+
public static int intRnd(int value1, int value2) {
9+
10+
if (value1 == value2) {
11+
return value1;
12+
}
13+
14+
int minValue = Integer.min(value1, value2);
15+
int maxValue = Integer.max(value1, value2);
16+
17+
int range = maxValue - minValue + 1;
18+
19+
return RND.nextInt(range) + minValue;
20+
}
21+
22+
public static int intRnd(int value) {
23+
return intRnd(0, value);
24+
}
25+
}

0 commit comments

Comments
 (0)