I ran Main.java with "Frightened" as the initial mode. I expected to see a maze drawn on the console. Instead, I got this output from the Eclipse: User Input: Please, specify your name: Aleksa Please specify the difficulty (Easy, Medium, Hard): Easy User Output: java.util.NoSuchElementException: No line found at java.base/java.util.Scanner.nextLine(Scanner.java:1651) at Game.Mode.initModes(Mode.java:85) at Game.Game.gameInit(Game.java:43) at Game.Main.main(Main.java:20) Algorithm file src/Resource/easyAlgorithmData.txt not found Ghost algorithms init failed!
I realized that when I deleted FrightenedWandering from the easyGhostAlgorithm.txt, the scanner.next() was called from boolean initModes(String) in Mode.java, although there is nothing more to read. Thus, a solution is to change the code in boolean initModes(String) like this: if(scanner.hasNext()) { for (int j = 0; j < numGhosts; j++) { tempMode.addAlgorithm(scanner.nextLine()); } }