Bug 697

Summary: Cannot infer type arguments for HashMap<>
Product: River-Crossing-Puzzle-Solver Reporter: tsunychau2-c
Component: Solver ModeAssignee: tsunychau2-c
Status: RESOLVED FIXED    
Severity: critical    
Priority: Normal    
Version: v0.1.0   
Hardware: PC   
OS: Mac OS   

Description tsunychau2-c 2022-11-05 22:09:41 HKT
Way to Reproduce:

1. Run Main.java inside the folder Default

2. Input "1" in the console for choosing solver mode

3. Input "1" in the console for choosing game level

Actual result:

Exception in thread "main" java.lang.Error: Unresolved compilation problems: 
	Cannot infer type arguments for HashMap<>
	Cannot infer type arguments for HashMap<>

	at Puzzle.PuzzleState.<init>(PuzzleState.java:24)
	at Puzzle.Puzzle.<init>(Puzzle.java:54)
	at Puzzle.UI.SolverModeController.<init>(SolverModeController.java:14)
	at Puzzle.UI.SolverMode.<init>(SolverMode.java:31)
	at Puzzle.UI.GameFlowFactory.getGameFlow(GameFlowFactory.java:6)
	at Puzzle.UI.Main.main(Main.java:34)
	at Default.Main.main(Main.java:5)

Expect Result:

No error shown
Comment 1 tsunychau2-c 2022-11-05 22:09:55 HKT
Bug is confirmed
Comment 2 tsunychau2-c 2022-11-05 22:11:19 HKT
In PuzzleState.java, on line 24 and 25, HashSet should be used instead of HashMap.

Modification of code:

public PuzzleState(ArrayList<String> landA, ArrayList<String> landB, int boatPos) {
		this.landA = landA;
		this.landB = landB;
		this.boatPos = boatPos;
		
		hashLandA = new HashSet<>(landA);
		hashLandB = new HashSet<>(landB);
	}