Identify the stations between which the travel time is smallest - Java Quiz Question



Write a program to identify the stations between which the travel time is smallest. The output string should be formatted as shown in the requirements below.

Input (List) Output (String)
[[Kavali-null-06:10-0], [Tettu-06:20-06:25-2], [Ulavapadu-06:50-06:55-10), [Singarayakonda-07:15-07:20-5], [Ongole-08:00-null-15]] The smallest travel time is 10 mins and it is between 'Kavali' and 'Tettu'
[[Nellore-null-10:00-0], [Ongole-11:30-11:40-30], [Guntur-12:30-12:50-28], [Vijayawada-14:05-14:40-35], [Kakinada-15:20-15:30-15], [Rajahmundry-16:00-16:05-18], [Visakhapatnam-17:35-null-45]] The smallest travel time is 30 mins and it is between 'Kakinada' and 'Rajahmundry'
[[Chennai-null-17:00-0], [Gudur-19:59-20:00-100], [Nellore-21:00-21:10-25], [Kavali-22:10-22:15-20], [Ongole-22:30-22:40-40], [Chirala-00:50-00:55-31], [Tenali Junction-03:30-03:35,31], [Vijayawada-05:40-05:45-45], [Hyderabad-06:59-07:05-100], [Karimnagar-08:35-null-60]] The smallest travel time is 40 mins and it is between 'Ongole' and 'Chirala'
[[Delhi-null-17:32-0], [Mathura Jun-20:50-20:55-141], [Agra Cantonment-00:10-00:15-54], [Gwalior-02:55-03:00-118], [Jhansi Junction-06:32-06:35-97], [Bhopal Junction-09:35-09:40-291], [Nagpur-12:45-12:50-389], [Chandrapur-16:00-16:05-197], [Balharshah-19:05-19:12-14], [Sirpur Kagaznagar-22:30-22:35-70], [Belampalli-01:55-02:00-38], [Mancheral-05:10-05:12-20], [Ramagundam-08:30-08:35-14], [Kazipet Junction-13:40-13:45-92], [Secunderabad Junction-16:30-16:35-132], [Hyderabad Deccan-19:50-null-10]] The smallest travel time is 2hrs 40 mins and it is between 'Agra Cantonment' and 'Gwalior'

class SmallestTravelTime

{    public static void main(String s[])
    {
        ArrayList journey = new ArrayList();
        journey.add(new Destination("Chennai", null, "17:00", 0));
        journey.add(new Destination("Gudur", "19:59", "20:20", 100));
        journey.add(new Destination("Nellore", "21:00", "21:10", 25));
        journey.add(new Destination("Kavali", "21:30", "21:35", 20));
        journey.add(new Destination("Ongole", "22:30", "22:40", 40));
        journey.add(new Destination("Chirala", "23:30", "23:35", 31));
        journey.add(new Destination("Tenali Junction", "00:30", "00:35", 31));
        journey.add(new Destination("Vijayawada", "01:05", "01:35", 45));
        journey.add(new Destination("Hyderabad", "03:20", "03:50", 100));
        journey.add(new Destination("Karimnagar", "05:35", null, 60));
        System.out.println(getTime(journey));

    }


private static String getTime(ArrayList<Destination> journey) {
//Write code here to get the smallest travelled time of the train
}

//Write additional methods here if required
}
class Destination {

String cityName;
String arrivalTime;
String depatureTime;
int kiloMeters;

public Destination(String cityName, String arrivalTime, String depatureTime, Integer kiloMeters) {
this.cityName = cityName;
this.arrivalTime = arrivalTime;
this.depatureTime = depatureTime;
this.kiloMeters = kiloMeters;
}

@Override
public String toString() {
return "[" + cityName + "-" + arrivalTime + "-" + depatureTime + "-" + kiloMeters + "]";
}
}