Skip to content
Extraits de code Groupes Projets
Valider d8951f6d rédigé par SIM's avatar SIM
Parcourir les fichiers

Premier commit juste pour tester avec la fonction factorielle

parent 1ef2858a
Aucune branche associée trouvée
Aucune étiquette associée trouvée
1 requête de fusion!1Premier commit juste pour tester avec la fonction factorielle
<?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>org.example</groupId>
<artifactId>SIM-Algo</artifactId>
<groupId>com.example</groupId>
<artifactId>mon-projet</artifactId>
<version>1.0-SNAPSHOT</version>
<properties>
<maven.compiler.source>23</maven.compiler.source>
<maven.compiler.target>23</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>17</maven.compiler.source> <!-- Java source version -->
<maven.compiler.target>17</maven.compiler.target> <!-- Java target version -->
<junit.version>5.9.2</junit.version> <!-- Dernière version stable de JUnit -->
<javagrader.version>1.0.6</javagrader.version> <!-- Version actuelle de JavaGrader -->
</properties>
<dependencies>
<!-- JUnit Jupiter API pour les tests -->
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>${junit.version}</version>
<scope>test</scope>
</dependency>
<!-- JUnit Jupiter Engine pour exécuter les tests -->
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>${junit.version}</version>
<scope>test</scope>
</dependency>
<!-- JavaGrader pour l'évaluation automatisée des réponses -->
<dependency>
<groupId>io.github.ucl-ingi</groupId>
<artifactId>JavaGrader</artifactId>
<version>${javagrader.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<!-- Maven Compiler Plugin pour choisir la version de Java -->
<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>
<!-- Maven Surefire Plugin pour exécuter les tests JUnit -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.0.0-M8</version>
<configuration>
<includes>
<include>**/*Test.java</include>
</includes>
</configuration>
</plugin>
</plugins>
</build>
</project>
\ No newline at end of file
package org.example;
public class Main {
public static void main(String[] args) {
System.out.println("Hello, World!");
......
package algorithms;
public class Factorial {
public static int calculate(int n){
return factorial(n, 1);
}
private static int factorial(int n, int result ){
if(n == 0){
return result;
}
return factorial(n-1, result * n);
}
}
import algorithms.Factorial;
import org.javagrader.Grade;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.*;
@Grade
public class FactorialTest {
@Test
@Grade(value = 1)
public void testFactorial(){
assertEquals(6, Factorial.calculate(3));
}
}
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter