用户输入不在文本下方打印
User Input not Printing below text
我试图让文本写得慢,然后使用 do-while 循环,但是当我 运行 我得到代码时:在下面输入文本 >: 应该是这样的:在下面输入文本:> 在此之下,我尝试将其从 print 更改为 println 但没有任何效果。我需要一些帮助
public class 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);
//[...]
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(" >: ");
//[...]
像这样尝试。
如果你完成循环,你将跳转到下一行。
我试图让文本写得慢,然后使用 do-while 循环,但是当我 运行 我得到代码时:在下面输入文本 >: 应该是这样的:在下面输入文本:> 在此之下,我尝试将其从 print 更改为 println 但没有任何效果。我需要一些帮助
public class 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);
//[...]
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(" >: ");
//[...]
像这样尝试。 如果你完成循环,你将跳转到下一行。