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/myKitten/.gitignore | 38 ++++++ graphs/java/myKitten/assembly.xml | 20 +++ graphs/java/myKitten/pom.xml | 138 +++++++++++++++++++++ .../fr/epita/assistants/mykitten/MyKitten.java | 64 ++++++++++ 4 files changed, 260 insertions(+) create mode 100644 graphs/java/myKitten/.gitignore create mode 100644 graphs/java/myKitten/assembly.xml create mode 100644 graphs/java/myKitten/pom.xml create mode 100644 graphs/java/myKitten/src/main/java/fr/epita/assistants/mykitten/MyKitten.java (limited to 'graphs/java/myKitten') diff --git a/graphs/java/myKitten/.gitignore b/graphs/java/myKitten/.gitignore new file mode 100644 index 0000000..5ff6309 --- /dev/null +++ b/graphs/java/myKitten/.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/myKitten/assembly.xml b/graphs/java/myKitten/assembly.xml new file mode 100644 index 0000000..4a8c128 --- /dev/null +++ b/graphs/java/myKitten/assembly.xml @@ -0,0 +1,20 @@ + + + tests + + jar + + false + + + / + true + + true + true + test + + + \ No newline at end of file diff --git a/graphs/java/myKitten/pom.xml b/graphs/java/myKitten/pom.xml new file mode 100644 index 0000000..e74e346 --- /dev/null +++ b/graphs/java/myKitten/pom.xml @@ -0,0 +1,138 @@ + + + 4.0.0 + fr.epita.assistants + myKitten + 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 + + + org.javassist + javassist + 3.29.2-GA + + + + + + + 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/myKitten/src/main/java/fr/epita/assistants/mykitten/MyKitten.java b/graphs/java/myKitten/src/main/java/fr/epita/assistants/mykitten/MyKitten.java new file mode 100644 index 0000000..e63c2f7 --- /dev/null +++ b/graphs/java/myKitten/src/main/java/fr/epita/assistants/mykitten/MyKitten.java @@ -0,0 +1,64 @@ +package fr.epita.assistants.mykitten; + +import java.io.IOException; +import java.nio.charset.StandardCharsets; +import java.nio.file.Files; +import java.nio.file.Paths; +import java.util.stream.Stream; + +public class MyKitten { + /** + * Initializer. + * + * @param srcPath Source file path. + */ + public MyKitten(String srcPath) { + try { + this.streamContent = Files.lines(Paths.get(srcPath)); + } catch (IOException e) { + throw new RuntimeException(e); + } + } + + /** + * Use the streamContent to replace `wordToReplace` with "miaou". Don't forget + * to add the line number beforehand for each line. Store the new + * result directly in the streamContent field. + * + * @param wordToReplace The word to replace + */ + public void replaceByMiaou(String wordToReplace) { + final int[] line = {1}; + this.streamContent = this.streamContent.map(i -> line[0]++ + " " + i).map(i -> i.replace(wordToReplace, "miaou")); + } + + /** + * Use the streamContent to write the content into the destination file. + * + * @param destPath Destination file path. + */ + public void toFile(String destPath) { + try { + Files.write(Paths.get(destPath), this.streamContent.toList(), StandardCharsets.UTF_8); + } catch (IOException e) { + throw new RuntimeException(e); + } + } + + /** + * Creates an instance of MyKitten and calls the above methods to do it + * straightforwardly. + * + * @param srcPath Source file path + * @param destPath Destination file path + * @param wordToReplace Word to replace + */ + public static void miaou(String srcPath, String destPath, + String wordToReplace) { + MyKitten chatteDeTaDaronne = new MyKitten(srcPath); + chatteDeTaDaronne.replaceByMiaou(wordToReplace); + chatteDeTaDaronne.toFile(destPath); + } + + public Stream streamContent; +} -- cgit v1.2.3