Bug 606 - Failed initialization of ghost algorithms
Summary: Failed initialization of ghost algorithms
Status: RESOLVED FIXED
Alias: None
Product: Group14-Pacman
Classification: Unclassified
Component: Game (show other bugs)
Version: 0.0.1
Hardware: PC Windows
: High critical
Assignee: Omar MOUSTAFA
URL:
Depends on:
Blocks:
 
Reported: 2021-11-24 15:38 HKT by Aleksa
Modified: 2021-12-06 22:58 HKT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Aleksa 2021-11-24 15:38:22 HKT
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!
Comment 1 Aleksa 2021-11-24 15:43:44 HKT
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());
					}
				}