Bug 551

Summary: The shortest path cannot be displayed
Product: New-Territories-Cycle-Track-Navigation-System Reporter: huiqizou2-c
Component: CyclingModeAssignee: huiqizou2-c
Status: RESOLVED FIXED    
Severity: normal CC: ruiruyang2-c
Priority: Normal    
Version: 1.0   
Hardware: PC   
OS: Mac OS   

Description huiqizou2-c 2021-11-10 11:22:34 HKT
When the entered indexes of the added attractions are in descending order, the shortest path cannot be computed. The exception java.lang.IndexOutOfBoundsException: Index 0 out of bounds for length 0 shows.

Step to Reproduce:
Set 0 as the departure and 6 as the destination. Enter '5 2' when the program prompts 'Please choose attractions'.

Actual Result: 
The shortest path from the attraction with index 5 to the attraction with index 2 doesn't show and the exception appears.


Expected Result: 
All shortest paths from the attraction with index 5 to the attraction with index 2 are displayed in the screen for the user to select.
Comment 1 huiqizou2-c 2021-12-02 18:00:27 HKT
Solution: The function dijkstra is moved into the for loop inside the function routePlanning(). Because for each place in the ArrayList places, the function should be executed once to plan the route between every two sites according to the preset priority.