我试图让文本写得很慢,然后使用do-while循环,但是当我运行代码时,我得到:在下面输入文本>:当应该像这样:在下面输入文本,并在下面加上:>,我已经尝试将其从print更改为println,但没有任何效果。我需要帮助
公共类Quick_Time_Event_Base_Code {
public static void main(String[] args) throws InterruptedException {
// Creates a quick time event where if the player doesn't input the right command
// then you "Fail" but if you input the correct code, you break out of the loop and "Pass"
String message = "Enter Text Below";
char[] chars = message.toCharArray();
for (int i = 0; i < chars.length; i++) {
System.out.print(chars[i]);
Thread.sleep(100);
}
Scanner input = new Scanner(System.in);
do {
System.out.println(" >: ");
System.out.flush();
String pass = input.nextLine();
if (pass.equals("Example Input Here")) {
break;
}
System.out.println(" You Failed the Quick Time Event");
System.exit(0);
} while (true);
答案 0 :(得分:0)
//[...]
char[] chars = message.toCharArray();
for (int i = 0; i < chars.length; i++) {
System.out.print(chars[i]);
Thread.sleep(100);
}
System.out.println("");
Scanner input = new Scanner(System.in);
do {
System.out.println(" >: ");
//[...]
像这样尝试。 如果完成循环,您将跳至下一行。