Bug 424

Summary: It's found that when the player won the game, the eclipse would prompt a "null pointer" error.
Product: CandyCrush 2020 Reporter: jli262-c
Component: Source CodeAssignee: jli262-c
Status: CONFIRMED ---    
Severity: enhancement    
Priority: ---    
Version: 1.0   
Hardware: PC   
OS: Windows   
Attachments: This is the final mentioned class in the error prompt.

Description jli262-c 2020-11-19 10:56:54 HKT
Created attachment 47 [details]
This is the final mentioned class in the error prompt.

Summary:
When the player played several swaps, and won the game, the eclipse would prompt "Exception in thread "main" java.lang.NullPointerException".

Steps to reproduce:
1. Run the program;
2. Input your swaps and finally win the game.

Actual Results:
Exception in thread "main" java.lang.NullPointerException: Cannot invoke "game.GameController.terminateGame()" because "this.theGC" is null
	at game.ScoreBoardHandler.update(ScoreBoardHandler.java:36)
	at game.GameController.updateScore(GameController.java:38)
	at game.Map.destroyDestoyable(Map.java:198)
	at game.Map.destroyRoutine(Map.java:346)
	at game.Map.swapItem(Map.java:312)
	at game.MapController.swapItems(MapController.java:53)
	at game.GameController.swapItems(GameController.java:42)
	at game.UserInputHandler.handleUserInput(UserInputHandler.java:79)
	at game.UserInputHandler.getUserInput(UserInputHandler.java:44)
	at game.GameController.startGame(GameController.java:31)
	at game.Main.main(Main.java:9)
Remaining Steps: 15; Score: 52
Congratulations!

Expected Results:
Remaining Steps: 15; Score: 52
Congratulations!
Comment 1 jli262-c 2020-11-19 14:22:43 HKT
(In reply to jli262-c from comment #0)
> Created attachment 47 [details]
> This is the final mentioned class in the error prompt.
> 
> Summary:
> When the player played several swaps, and won the game, the eclipse would
> prompt "Exception in thread "main" java.lang.NullPointerException".
> 
> Steps to reproduce:
> 1. Run the program;
> 2. Input your swaps and finally win the game.
> 
> Actual Results:
> Exception in thread "main" java.lang.NullPointerException: Cannot invoke
> "game.GameController.terminateGame()" because "this.theGC" is null
> 	at game.ScoreBoardHandler.update(ScoreBoardHandler.java:36)
> 	at game.GameController.updateScore(GameController.java:38)
> 	at game.Map.destroyDestoyable(Map.java:198)
> 	at game.Map.destroyRoutine(Map.java:346)
> 	at game.Map.swapItem(Map.java:312)
> 	at game.MapController.swapItems(MapController.java:53)
> 	at game.GameController.swapItems(GameController.java:42)
> 	at game.UserInputHandler.handleUserInput(UserInputHandler.java:79)
> 	at game.UserInputHandler.getUserInput(UserInputHandler.java:44)
> 	at game.GameController.startGame(GameController.java:31)
> 	at game.Main.main(Main.java:9)
> Remaining Steps: 15; Score: 52
> Congratulations!
> 
> Expected Results:
> Remaining Steps: 15; Score: 52
> Congratulations!

No initialization for the object of GameController class.
Add "theGC = GameController.getInstance" and everything is OK.