Closed evgenyigumnov closed 1 day ago
Create Folder "java"
Create a new directory named java.
java
Copy Files into "java" Folder
Copy prompt.txt into the java folder.
prompt.txt
rustsn --lang=java
take 2 params and add them and return result
pom.xml
<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>com.example</groupId> <artifactId>solution</artifactId> <version>1.0.0</version> <packaging>jar</packaging> <description>Minimalistic project</description> <properties> <maven.compiler.source>17</maven.compiler.source> <maven.compiler.target>17</maven.compiler.target> <junit.version>5.9.0</junit.version> </properties> <dependencies> <dependency> <groupId>org.junit.jupiter</groupId> <artifactId>junit-jupiter</artifactId> <version>${junit.version}</version> <scope>test</scope> </dependency> </dependencies> <build> <plugins> <!-- Compiler Plugin --> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>3.10.1</version> <configuration> <source>${maven.compiler.source}</source> <target>${maven.compiler.target}</target> </configuration> </plugin> <!-- Surefire Plugin for Testing --> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <version>3.0.0-M7</version> </plugin> </plugins> </build> </project>
src/main/java/com/example/solution/Solution.java
package com.example.solution; public class Solution { public int add(int a, int b) { return a + b; } // Overloaded method to handle String and int public String add(String a, int b) { return a + b; } }
src/test/java/com/example/solution/SolutionTest.java
package com.example.solution; import org.junit.jupiter.api.Test; import static org.junit.jupiter.api.Assertions.*; class SolutionTest { private final Solution solution = new Solution(); @Test void testAddPositiveNumbers() { assertEquals(3, solution.add(1, 2)); } @Test void testAddNegativeNumbers() { assertEquals(-3, solution.add(-1, -2)); } @Test void testAddStringAndInt() { assertEquals("12", solution.add("1", 2)); } }
mvn install
mvn compile
mvn test
Create Folder "java"
Create a new directory named
java
.Copy Files into "java" Folder
Copy
prompt.txt
into thejava
folder.Launch Example
Example Query
Example Generation
pom.xml
src/main/java/com/example/solution/Solution.java
src/test/java/com/example/solution/SolutionTest.java
Example Install Dependencies
Example Compile the Project
Example Run Tests