diff options
| author | Martial Simon <msimon_fr@hotmail.com> | 2025-09-15 01:08:27 +0200 |
|---|---|---|
| committer | Martial Simon <msimon_fr@hotmail.com> | 2025-09-15 01:08:27 +0200 |
| commit | c9b6b9a5ca082fe7c1b6f58d7713f785a9eb6a5c (patch) | |
| tree | 3e4f42f93c7ae89a364e4d51fff6e5cec4e55fa9 /graphs/java/myKitten | |
add: graphs et rushs
Diffstat (limited to 'graphs/java/myKitten')
| -rw-r--r-- | graphs/java/myKitten/.gitignore | 38 | ||||
| -rw-r--r-- | graphs/java/myKitten/assembly.xml | 20 | ||||
| -rw-r--r-- | graphs/java/myKitten/pom.xml | 138 | ||||
| -rw-r--r-- | graphs/java/myKitten/src/main/java/fr/epita/assistants/mykitten/MyKitten.java | 64 |
4 files changed, 260 insertions, 0 deletions
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 @@ + +<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0 http://maven.apache.org/xsd/assembly-1.1.0.xsd"> + <id>tests</id> + <formats> + <format>jar</format> + </formats> + <includeBaseDirectory>false</includeBaseDirectory> + <dependencySets> + <dependencySet> + <outputDirectory>/</outputDirectory> + <useProjectArtifact>true</useProjectArtifact> + <!-- we're creating the test-jar as an attachement --> + <useProjectAttachments>true</useProjectAttachments> + <unpack>true</unpack> + <scope>test</scope> + </dependencySet> + </dependencySets> +</assembly>
\ 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 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project xmlns="http://maven.apache.org/POM/4.0.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + <groupId>fr.epita.assistants</groupId> + <artifactId>myKitten</artifactId> + <version>1.0</version> + + <properties> + <versions.java>21</versions.java> + <versions.junit>5.9.1</versions.junit> + <versions.maven-compiler-plugin>3.13.0</versions.maven-compiler-plugin> + <versions.maven-surefire-plugin>3.5.0</versions.maven-surefire-plugin> + <versions.maven-jar-plugin>3.1.1</versions.maven-jar-plugin> + <versions.maven-install-plugin>3.1.0</versions.maven-install-plugin> + + <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> + + <surefire.reportsDirectory>${project.build.directory}/surefire-reports</surefire.reportsDirectory> + </properties> + + <dependencies> + <dependency> + <groupId>org.junit.jupiter</groupId> + <artifactId>junit-jupiter</artifactId> + <version>${versions.junit}</version> + </dependency> + <dependency> + <groupId>org.apache.maven.surefire</groupId> + <artifactId>surefire-junit-platform</artifactId> + <version>${versions.maven-surefire-plugin}</version> + </dependency> + <dependency> + <groupId>org.apache.maven</groupId> + <artifactId>maven-compat</artifactId> + <version>3.9.8</version> + </dependency> + <dependency> + <groupId>org.apache.maven</groupId> + <artifactId>maven-plugin-api</artifactId> + <version>3.9.8</version> + </dependency> + <dependency> + <groupId>org.apache.maven</groupId> + <artifactId>maven-project</artifactId> + <version>2.2.1</version> + </dependency> + <dependency> + <groupId>org.apache.maven</groupId> + <artifactId>maven-core</artifactId> + <version>3.8.1</version> + </dependency> + <dependency> + <groupId>org.apache.maven</groupId> + <artifactId>maven-monitor</artifactId> + <version>2.2.1</version> + </dependency> + <dependency> + <groupId>org.codehaus.plexus</groupId> + <artifactId>plexus-utils</artifactId> + <version>3.0.24</version> + </dependency> + <dependency> + <groupId>org.apache.maven.shared</groupId> + <artifactId>maven-filtering</artifactId> + <version>3.3.2</version> + </dependency> + <dependency> + <groupId>org.codehaus.plexus</groupId> + <artifactId>plexus-interpolation</artifactId> + <version>1.13</version> + </dependency> + <dependency> + <groupId>org.apache.maven</groupId> + <artifactId>maven-profile</artifactId> + <version>2.2.1</version> + </dependency> + <dependency> + <groupId>org.apache.maven</groupId> + <artifactId>maven-artifact-manager</artifactId> + <version>2.2.1</version> + </dependency> + <dependency> + <groupId>org.apache.maven</groupId> + <artifactId>maven-plugin-registry</artifactId> + <version>2.2.1</version> + </dependency> + <dependency> + <groupId>org.apache.maven</groupId> + <artifactId>maven-repository-metadata</artifactId> + <version>2.2.1</version> + </dependency> + <dependency> + <groupId>classworlds</groupId> + <artifactId>classworlds</artifactId> + <version>1.1</version> + </dependency> + <dependency> + <groupId>org.junit.platform</groupId> + <artifactId>junit-platform-commons</artifactId> + <version>1.9.3</version> + </dependency> + <dependency> + <groupId>org.javassist</groupId> + <artifactId>javassist</artifactId> + <version>3.29.2-GA</version> + </dependency> + </dependencies> + + <build> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-compiler-plugin</artifactId> + <version>${versions.maven-compiler-plugin}</version> + <configuration> + <source>${versions.java}</source> + <target>${versions.java}</target> + </configuration> + </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-install-plugin</artifactId> + <version>${versions.maven-install-plugin}</version> + </plugin> + + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-surefire-plugin</artifactId> + <version>${versions.maven-surefire-plugin}</version> + <configuration> + <reportsDirectory>${surefire.reportsDirectory}</reportsDirectory> + </configuration> + </plugin> + </plugins> + </build> +</project> 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<String> streamContent; +} |
