Bug 424 - It's found that when the player won the game, the eclipse would prompt a "null pointer" error.
Summary: It's found that when the player won the game, the eclipse would prompt a "nul...
Status: CONFIRMED
Alias: None
Product: CandyCrush 2020
Classification: Unclassified
Component: Source Code (show other bugs)
Version: 1.0
Hardware: PC Windows
: --- enhancement
Assignee: jli262-c
URL:
Depends on:
Blocks:
 
Reported: 2020-11-19 10:56 HKT by jli262-c
Modified: 2020-11-29 15:05 HKT (History)
0 users

See Also:


Attachments
This is the final mentioned class in the error prompt. (1.26 KB, text/plain)
2020-11-19 10:56 HKT, jli262-c
Details

Note You need to log in before you can comment on or make changes to this bug.
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.