|
@@ -8,6 +8,7 @@ package org.openzen.javascriptingexample;
|
8
|
8
|
import java.io.BufferedReader;
|
9
|
9
|
import java.io.IOException;
|
10
|
10
|
import java.io.InputStreamReader;
|
|
11
|
+import java.util.Random;
|
11
|
12
|
import org.openzen.zencode.java.ZenCodeGlobals;
|
12
|
13
|
|
13
|
14
|
/**
|
|
@@ -15,6 +16,8 @@ import org.openzen.zencode.java.ZenCodeGlobals;
|
15
|
16
|
* @author Hoofdgebruiker
|
16
|
17
|
*/
|
17
|
18
|
public class Globals implements ZenCodeGlobals {
|
|
19
|
+ private static final Random RANDOM = new Random();
|
|
20
|
+
|
18
|
21
|
@Global
|
19
|
22
|
public static void println(String message) {
|
20
|
23
|
System.out.println(message);
|
|
@@ -23,11 +26,17 @@ public class Globals implements ZenCodeGlobals {
|
23
|
26
|
@Global
|
24
|
27
|
public static String readLine(String prompt) {
|
25
|
28
|
System.out.print(prompt);
|
26
|
|
- try (BufferedReader reader = new BufferedReader(new InputStreamReader(System.in))) {
|
|
29
|
+ try {
|
|
30
|
+ BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
|
27
|
31
|
return reader.readLine();
|
28
|
32
|
} catch (IOException ex) {
|
29
|
33
|
ex.printStackTrace();
|
30
|
34
|
return "";
|
31
|
35
|
}
|
32
|
36
|
}
|
|
37
|
+
|
|
38
|
+ @Global
|
|
39
|
+ public static int randomInt(int limit) {
|
|
40
|
+ return RANDOM.nextInt(limit);
|
|
41
|
+ }
|
33
|
42
|
}
|