Skip to content

Commit 148f8d3

Browse files
committed
add randInt
1 parent 6481f6c commit 148f8d3

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

src/main/java/Random.java

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,23 @@
11
public class Random {
2+
public int RandInt() {
3+
java.util.Random rand = new java.util.Random();
4+
return rand.nextInt(90000) + 10000;
5+
}
6+
7+
public int RandInt(int min, int max) {
8+
java.util.Random rand = new java.util.Random();
9+
return rand.nextInt(max - min) + min;
10+
}
11+
12+
public int RandInt(int seed) {
13+
java.util.Random rand = new java.util.Random(seed);
14+
return rand.nextInt(90000) + 10000;
15+
}
16+
217
public static void main(String[] args) {
3-
System.out.println(new java.util.Random().nextInt(90000) + 10000 + "");
18+
Random random = new Random();
19+
System.out.println(random.RandInt(1, 20));
20+
System.out.println(random.RandInt());
21+
System.out.println(random.RandInt(123));
422
}
523
}

0 commit comments

Comments
 (0)