Bug 595 - Eclipse throws an exception after I input second command to PacMan
Summary: Eclipse throws an exception after I input second command to PacMan
Status: RESOLVED FIXED
Alias: None
Product: Group14-Pacman
Classification: Unclassified
Component: Game (show other bugs)
Version: 0.0.1
Hardware: PC Windows
: High major
Assignee: Aleksa
URL:
Depends on:
Blocks:
 
Reported: 2021-11-21 01:03 HKT by Aleksa
Modified: 2021-11-21 02:08 HKT (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Aleksa 2021-11-21 01:03:07 HKT
I ran Main.java and started controlling PacMan. I input "RIGHT" and he went "RIGHT". But when I input "UP" I got this output from Eclipse:

Exception in thread "main" java.util.NoSuchElementException
	at java.base/java.util.Scanner.throwFor(Scanner.java:937)
	at java.base/java.util.Scanner.next(Scanner.java:1478)
	at Game.Game.gameTick(Game.java:39)
	at Game.Main.main(Main.java:16)
Comment 1 Aleksa 2021-11-21 01:05:31 HKT
The solution was to move the Scanner from gameTick() in Game.java to Main.java. Constant opening and closing the Scanner causes the problem