Bug 551 - The shortest path cannot be displayed
Summary: The shortest path cannot be displayed
Status: RESOLVED FIXED
Alias: None
Product: New-Territories-Cycle-Track-Navigation-System
Classification: Unclassified
Component: CyclingMode (show other bugs)
Version: 1.0
Hardware: PC Mac OS
: Normal normal
Assignee: huiqizou2-c
URL:
Depends on:
Blocks:
 
Reported: 2021-11-10 11:22 HKT by huiqizou2-c
Modified: 2021-12-02 18:00 HKT (History)
1 user (show)

See Also:


Attachments

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