Skip to content
Snippets Groups Projects
Commit a64954d1 authored by Pedro Pablo Cardona Arroyave's avatar Pedro Pablo Cardona Arroyave
Browse files

Format time method was fixed

parent f083c1bf
Branches
No related tags found
No related merge requests found
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="RunConfigurationProducerService">
<option name="ignoredProducers">
<set>
<option value="com.android.tools.idea.compose.preview.runconfiguration.ComposePreviewRunConfigurationProducer" />
</set>
</option>
</component>
</project>
\ No newline at end of file
No preview for this file type
No preview for this file type
...@@ -6,14 +6,14 @@ public class Main { ...@@ -6,14 +6,14 @@ public class Main {
try { try {
Graph g = new Graph("noder.txt"); Graph g = new Graph("noder.txt");
g.loadEdges("kanter.txt"); g.loadEdges("kanter.txt");
Edge lastEdge= g.getShortestPath(2518780,232073); Edge lastEdge= g.getShortestPath(4247796,232073);
int sum = 0; int sum = 0;
while (lastEdge!=null) { while (lastEdge!=null) {
System.out.println(lastEdge.getDestination()); System.out.println(lastEdge.getDestination());
lastEdge = lastEdge.previousEdge;
sum += lastEdge.drivingTime; sum += lastEdge.drivingTime;
lastEdge = lastEdge.previousEdge;
} }
System.out.println(0); System.out.println(4247796);
System.out.println("-------------------------------------------"); System.out.println("-------------------------------------------");
System.out.println(Utils.formatTime(sum)); System.out.println(Utils.formatTime(sum));
} catch (Exception e) { } catch (Exception e) {
......
...@@ -86,9 +86,19 @@ class Utils { ...@@ -86,9 +86,19 @@ class Utils {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
if (time / 360000 > 0) sb.append(time / 360000).append(":"); if (time / 360000 > 0) sb.append(time / 360000).append(":");
int minutes = time % 360000; int minutes = time % 360000;
if (minutes / 6000 > 0) sb.append(minutes / 6000).append(":"); if (minutes / 6000 > 0){
if(minutes/6000 > 9){
sb.append(minutes / 6000).append(":");
} else {
sb.append(0).append(minutes / 6000).append(":");
}
}
int seconds = time % 6000; int seconds = time % 6000;
if((seconds/100) > 9){
sb.append(seconds/100); sb.append(seconds/100);
} else {
sb.append(0).append(seconds/100);
}
return sb.toString(); return sb.toString();
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment