-
Notifications
You must be signed in to change notification settings - Fork 6
Open
Description
If the program crashes in Nooblab (java), and you keep giving it input after that, and then restart the program, it will reuse the data that was inserted after the program crashed.
Try the following program:
import java.util.Scanner;
public class Main
{
public static void main(String[] args)
{
Scanner scanner = new Scanner(System.in);
boolean isRunning = true;
/* Start the main program loop */
while (isRunning)
{
System.out.println("==== Edu Track - main menu ====");
System.out.println("1. Input data");
System.out.println("2. Crash the program");
System.out.println("3. Exit");
System.out.print("Input: ");
String option = scanner.nextLine();
if (option.equals("1"))
{
System.out.println("You selected option #1");
}
else if (option.equals("2"))
{
throw new RuntimeException("I haz died!");
}
else {
isRunning = false;
}
}
}
}Steps to reproduce:
- Run the program
- Selection option #2
- Click on the terminal, input 1 [enter] 3 [Enter]
- Run the program again
It will print "You selected option #1" and then exit, which proofs that the data inputted into the terminal before the program run was reused.
I think this could be the source of issues when students sometimes report: "The test isn't working until I reload the page".
Would it be useful to flush the terminal before running the program?
Metadata
Metadata
Assignees
Labels
No labels