| Summary: | A non-travelable role can across the river | ||
|---|---|---|---|
| Product: | River-Crossing-Puzzle-Solver | Reporter: | tsunychau2-c |
| Component: | Logic | Assignee: | tsunychau2-c |
| Status: | RESOLVED FIXED | ||
| Severity: | major | ||
| Priority: | High | ||
| Version: | v0.9.5 | ||
| Hardware: | PC | ||
| OS: | Mac OS | ||
|
Description
tsunychau2-c
2022-11-05 19:57:10 HKT
Bug is confirmed The problem is fixed now. Since puzzle.getTravelables().containskey(role) in line 62 will always return true. It should be changed to puzzle.getTravelables().contains(role) and using hashset instead of hashmap.
Modification of code:
public boolean isTravelable(Move move)
{
ArrayList<String> travelers = move.getTravelers();
boolean travelFlag = false;
for (String role: travelers)
if(puzzle.getTravelables().contains(role) == true)
travelFlag = true;
return travelFlag;
}
|