Assignment instructions My professor wants us to use a hashmap along with an array to find the fastest route from one airport to another by plane given a list of flights. He wants us to populate the array as we traverse the hashmap finding the fastest flights from each airport to take. I have gotten as far as creating the hashmap with the destination of the flight along with the departure time and arrival time all in one cell of the linked list but when I attempt to extract the departure and arrival time of each flight leaving the airport to insert them into the array I cannot. Is there a way to extract a specific value from a linked list with multiple values in each cell inside of a hash or should I go about it another way? I have confirmed that the hashmap has the correct information and is functioning correctly I am just unable to or do not know how to access the information inside of the hashmap to send it through to the array. What the information inside the debugger looks like
LinkedHashMap<String, LinkedList<Info>> airportsHash = new LinkedHashMap<String, LinkedList<Info>>();
LinkedList<Info> destinations;
public Info (String destination, double departureTime, double arrivalTime){
this.destination = destination;
this.departureTime = departureTime;
this.arrivalTime = arrivalTime;
}
public void fillHash(String origin, String destination, double departureTime, double arrivalTime) {
if(airportsHash.containsKey(origin)){
destinations = airportsHash.get(origin);
destinations.add(new Info(destination, departureTime/100, arrivalTime/100));
}
else{
destinations = new LinkedList<Info>();
destinations.add(new Info(destination, departureTime/100, arrivalTime/100));
airportsHash.put(origin, destinations);
}
}
LinkedListclass. Similarly 'hashmap with the destination of the flight along with the departure time and arrival time all in one cell of the linked list' and 'each cell inside of a hash' are hard to picture without code. Could you provide some code to make it clearer how your structure works?