📄 javarandom.java
字号:
import java.io.*;
import java.util.Random;
public class JavaRandom {
public static void main(String[] args) throws IOException {
Random rand = new Random();
String str;
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
while (true) {
try {
str = in.readLine();
} catch (IOException e) {
continue;
}
if (str.indexOf("check_status") != -1)
System.out.print("ready");
else if (str.indexOf("beetlemove") != -1) {
switch (rand.nextInt(4)) {
case 0:
System.out.print("action up");
break;
case 1:
System.out.print("action down");
break;
case 2:
System.out.print("action left");
break;
case 3:
System.out.print("action right");
break;
}
} else if (str.indexOf("snailmove") != -1) {
switch (rand.nextInt(4)) {
case 0:
System.out.print("action up");
break;
case 1:
System.out.print("action down");
break;
case 2:
System.out.print("action left");
break;
case 3:
System.out.print("action right");
break;
}
}
System.out.flush();
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -