From c9b6b9a5ca082fe7c1b6f58d7713f785a9eb6a5c Mon Sep 17 00:00:00 2001 From: Martial Simon Date: Mon, 15 Sep 2025 01:08:27 +0200 Subject: add: graphs et rushs --- graphs/java/travel/.gitignore | 38 ++++++ graphs/java/travel/pom.xml | 138 +++++++++++++++++++++ .../java/fr/epita/assistants/travel/Country.java | 44 +++++++ .../java/fr/epita/assistants/travel/Travel.java | 13 ++ .../travel/src/main/resources/travel_times.csv | 29 +++++ 5 files changed, 262 insertions(+) create mode 100644 graphs/java/travel/.gitignore create mode 100644 graphs/java/travel/pom.xml create mode 100644 graphs/java/travel/src/main/java/fr/epita/assistants/travel/Country.java create mode 100644 graphs/java/travel/src/main/java/fr/epita/assistants/travel/Travel.java create mode 100644 graphs/java/travel/src/main/resources/travel_times.csv (limited to 'graphs/java/travel') diff --git a/graphs/java/travel/.gitignore b/graphs/java/travel/.gitignore new file mode 100644 index 0000000..5ff6309 --- /dev/null +++ b/graphs/java/travel/.gitignore @@ -0,0 +1,38 @@ +target/ +!.mvn/wrapper/maven-wrapper.jar +!**/src/main/**/target/ +!**/src/test/**/target/ + +### IntelliJ IDEA ### +.idea/modules.xml +.idea/jarRepositories.xml +.idea/compiler.xml +.idea/libraries/ +*.iws +*.iml +*.ipr + +### Eclipse ### +.apt_generated +.classpath +.factorypath +.project +.settings +.springBeans +.sts4-cache + +### NetBeans ### +/nbproject/private/ +/nbbuild/ +/dist/ +/nbdist/ +/.nb-gradle/ +build/ +!**/src/main/**/build/ +!**/src/test/**/build/ + +### VS Code ### +.vscode/ + +### Mac OS ### +.DS_Store \ No newline at end of file diff --git a/graphs/java/travel/pom.xml b/graphs/java/travel/pom.xml new file mode 100644 index 0000000..671d430 --- /dev/null +++ b/graphs/java/travel/pom.xml @@ -0,0 +1,138 @@ + + + 4.0.0 + fr.epita.assistants + travel + 1.0 + + + 21 + 5.9.1 + 3.13.0 + 3.5.0 + 3.1.1 + 3.1.0 + + UTF-8 + + ${project.build.directory}/surefire-reports + + + + + org.junit.jupiter + junit-jupiter + ${versions.junit} + + + org.apache.maven.surefire + surefire-junit-platform + ${versions.maven-surefire-plugin} + + + org.apache.maven + maven-compat + 3.9.8 + + + org.apache.maven + maven-plugin-api + 3.9.8 + + + org.apache.maven + maven-project + 2.2.1 + + + org.apache.maven + maven-core + 3.8.1 + + + org.apache.maven + maven-monitor + 2.2.1 + + + org.codehaus.plexus + plexus-utils + 3.0.24 + + + org.apache.maven.shared + maven-filtering + 3.3.2 + + + org.codehaus.plexus + plexus-interpolation + 1.13 + + + org.apache.maven + maven-profile + 2.2.1 + + + org.apache.maven + maven-artifact-manager + 2.2.1 + + + org.apache.maven + maven-plugin-registry + 2.2.1 + + + org.apache.maven + maven-repository-metadata + 2.2.1 + + + classworlds + classworlds + 1.1 + + + org.junit.platform + junit-platform-commons + 1.9.3 + + + com.opencsv + opencsv + 4.1 + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + ${versions.maven-compiler-plugin} + + ${versions.java} + ${versions.java} + + + + org.apache.maven.plugins + maven-install-plugin + ${versions.maven-install-plugin} + + + + org.apache.maven.plugins + maven-surefire-plugin + ${versions.maven-surefire-plugin} + + ${surefire.reportsDirectory} + + + + + diff --git a/graphs/java/travel/src/main/java/fr/epita/assistants/travel/Country.java b/graphs/java/travel/src/main/java/fr/epita/assistants/travel/Country.java new file mode 100644 index 0000000..e616e64 --- /dev/null +++ b/graphs/java/travel/src/main/java/fr/epita/assistants/travel/Country.java @@ -0,0 +1,44 @@ +package fr.epita.assistants.travel; + +import com.opencsv.CSVReader; + +import java.io.FileReader; +import java.time.ZoneId; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; + +public class Country { + String countryName; + public Map travelTimes; + ZoneId countryZone; + String filename; + + public Country(String countryName, String countryZone, String inputFilePath) { + this.countryName = countryName; + this.countryZone = ZoneId.of(countryZone); + this.filename = inputFilePath; + this.travelTimes = initTravelTimes(inputFilePath); + } + + public Map initTravelTimes(String inputFilePath) { + Map res = new HashMap<>(); + try { + CSVReader c = new CSVReader(new FileReader(inputFilePath)); + List lines = c.readAll(); + lines.removeFirst(); + for (String[] line : lines) { + if (Objects.equals(line[0], this.countryName)) { + res.put(line[1], Integer.parseInt(line[2])); + } + else if (Objects.equals(line[1], this.countryName)) { + res.put(line[0], Integer.parseInt(line[2])); + } + } + } catch (Exception e) { + throw new RuntimeException(e); + } + return res; + } +} diff --git a/graphs/java/travel/src/main/java/fr/epita/assistants/travel/Travel.java b/graphs/java/travel/src/main/java/fr/epita/assistants/travel/Travel.java new file mode 100644 index 0000000..9302e18 --- /dev/null +++ b/graphs/java/travel/src/main/java/fr/epita/assistants/travel/Travel.java @@ -0,0 +1,13 @@ +package fr.epita.assistants.travel; + +import java.time.ZonedDateTime; +import java.time.format.DateTimeFormatter; + +public class Travel { + public static void travelTo(Country source, Country destination) { + ZonedDateTime t1 = ZonedDateTime.now(source.countryZone); + ZonedDateTime t2 = ZonedDateTime.now(destination.countryZone).plusHours(source.travelTimes.get(destination.countryName)); + System.out.println("Boarding in " + source.countryName + ", local date and time is: " + t1.format(DateTimeFormatter.RFC_1123_DATE_TIME)); + System.out.println("Landing in " + destination.countryName + ", local date and time on arrival will be: " + t2.format(DateTimeFormatter.RFC_1123_DATE_TIME)); + } +} diff --git a/graphs/java/travel/src/main/resources/travel_times.csv b/graphs/java/travel/src/main/resources/travel_times.csv new file mode 100644 index 0000000..a6b720b --- /dev/null +++ b/graphs/java/travel/src/main/resources/travel_times.csv @@ -0,0 +1,29 @@ +source,destination,travel_time +France,Italy,1 +France,England,2 +France,Vietnam,12 +France,Chicago,9 +France,Brazil,12 +France,Egypt,4 +France,Australia,24 +Italy,England,3 +Italy,Vietnam,11 +Italy,Chicago,9 +Italy,Brazil,12 +Italy,Egypt,3 +Italy,Australia,17 +England,Vietnam,12 +England,Chicago,11 +England,Brazil,12 +England,Egypt,5 +England,Australia,21 +Vietnam,Chicago,21 +Vietnam,Brazil,21 +Vietnam,Egypt,17 +Vietnam,Australia,6 +Chicago,Brazil,13 +Chicago,Egypt,13 +Chicago,Australia,21 +Brazil,Egypt,17 +Brazil,Australia,21 +Egypt,Australia,19 \ No newline at end of file -- cgit v1.2.3