diff --git a/src/main/java/fr/u_paris/gla/project/io/NetworkFormat.java b/src/main/java/fr/u_paris/gla/project/io/NetworkFormat.java index ff95c99..0113744 100644 --- a/src/main/java/fr/u_paris/gla/project/io/NetworkFormat.java +++ b/src/main/java/fr/u_paris/gla/project/io/NetworkFormat.java @@ -33,10 +33,10 @@ public final class NetworkFormat { private static final DateTimeFormatter DURATION_FORMATTER = DateTimeFormatter .ofPattern("HH:mm:ss"); - private static final NumberFormat DURATION_SECONDS_FORMATTER = NumberFormat + private static final NumberFormat DURATION_INDIVIDUAL_FORMATTER = NumberFormat .getIntegerInstance(Locale.ENGLISH); static { - DURATION_SECONDS_FORMATTER.setMinimumIntegerDigits(2); + DURATION_INDIVIDUAL_FORMATTER.setMinimumIntegerDigits(2); } private static final Temporal ZERO = LocalTime.parse("00:00:00"); @@ -51,8 +51,8 @@ public final class NetworkFormat { } public static String formatDuration(Duration duration) { - return Long.toString(duration.toMinutes()) + ":" - + DURATION_SECONDS_FORMATTER.format(duration.toSecondsPart()); + return DURATION_INDIVIDUAL_FORMATTER.format(duration.toMinutes()) + ":" + + DURATION_INDIVIDUAL_FORMATTER.format(duration.toSecondsPart()); } /** Get a formatter for the numbers in a GPS coordinate pair diff --git a/src/main/java/fr/u_paris/gla/project/io/ScheduleFormat.java b/src/main/java/fr/u_paris/gla/project/io/ScheduleFormat.java index fc4d4ba..8a86594 100644 --- a/src/main/java/fr/u_paris/gla/project/io/ScheduleFormat.java +++ b/src/main/java/fr/u_paris/gla/project/io/ScheduleFormat.java @@ -5,6 +5,7 @@ package fr.u_paris.gla.project.io; import java.time.format.DateTimeFormatter; import java.time.format.ResolverStyle; +import java.util.ArrayList; import java.util.List; /** @@ -32,10 +33,13 @@ public final class ScheduleFormat { * @return the sequence of branching */ public static List getTripSequence(String representation) { - // TODO Read a trip sequence from a string - throw new RuntimeException("Not implemented yet"); - } + List l = new ArrayList<>(); + for(String s : representation.split(",")) + l.add(Integer.parseInt(s)); + return l; + } + public static DateTimeFormatter getTimeFormatter() { return DateTimeFormatter.ofPattern("HH:mm").withResolverStyle(ResolverStyle.LENIENT); diff --git a/src/test/java/fr/u_paris/gla/project/io/ScheduleFormatTest.java b/src/test/java/fr/u_paris/gla/project/io/ScheduleFormatTest.java index 4b0f749..f9eae35 100644 --- a/src/test/java/fr/u_paris/gla/project/io/ScheduleFormatTest.java +++ b/src/test/java/fr/u_paris/gla/project/io/ScheduleFormatTest.java @@ -13,8 +13,8 @@ import static org.junit.jupiter.api.Assertions.*; class ScheduleFormatTest { @Test - void getTripSequence() { - String rpz = "4, 5, 19, 21"; + public void getTripSequence() { + String rpz = "4,5,19,21"; List test = Arrays.asList(4, 5, 19, 21); assertEquals(test, ScheduleFormat.getTripSequence(rpz));