private String createResultString ( String strategyDescription , List < String > shortestRoute , double distance , long elapsedTime ) { StringBuilder buffer = new StringBuilder ( ) ; buffer . append ( ' ' ) ; buffer . append ( strategyDescription ) ; buffer . append ( "]\n" ) ; buffer . append ( "ROUTE: " ) ; for ( String s : shortestRoute ) { buffer . append ( s ) ; buffer . append ( " -> " ) ; } buffer . append ( shortestRoute . get ( 0 ) ) ; buffer . append ( ' ' ) ; buffer . append ( "TOTAL DISTANCE: " ) ; buffer . append ( String . valueOf ( distance ) ) ; buffer . append ( "km\n" ) ; buffer . append ( "(Search Time: " ) ; double seconds = ( double ) elapsedTime / 1000 ; buffer . append ( String . valueOf ( seconds ) ) ; buffer . append ( " seconds)\n\n" ) ; return buffer . toString ( ) ; }
Helper method for formatting a result as a string for display .