Skip to content
Snippets Groups Projects
Commit bad95a15 authored by Thomas BREIL's avatar Thomas BREIL
Browse files

Clean and rename Display class

parent c1f4d3aa
Branches main
No related tags found
No related merge requests found
......@@ -9,10 +9,10 @@ public class Main {
firstPlayer.changeMoney(400);
firstPlayer.addXp( 15);
System.out.println(Affichage.afficherJoueur(firstPlayer));
System.out.println(Display.afficherJoueur(firstPlayer));
System.out.println("------------------");
firstPlayer.addXp(20);
System.out.println(Affichage.afficherJoueur(firstPlayer));
System.out.println(Display.afficherJoueur(firstPlayer));
System.out.println("------------------");
......
package re.forestier.edu.rpg;
public class Affichage {
public class Display {
public static String afficherJoueur(Player player) {
final String[] finalString = {"Joueur " + player.avatarName + " joué par " + player.playerName};
finalString[0] += "\nNiveau : " + player.getLevel() + " (XP totale : " + player.xp + ")";
finalString[0] += "\n\nCapacités :";
player.abilities.forEach((name, level) -> {
finalString[0] += "\n " + name + " : " + level;
});
player.abilities.forEach((name, level) -> finalString[0] += "\n " + name + " : " + level);
finalString[0] += "\n\nInventaire :";
player.inventory.forEach(item -> {
finalString[0] += "\n " + item;
});
player.inventory.forEach(item -> finalString[0] += "\n " + item);
return finalString[0];
}
......
package re.forestier.edu;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import re.forestier.edu.rpg.Adventurer;
import re.forestier.edu.rpg.Affichage;
import re.forestier.edu.rpg.Display;
import java.util.ArrayList;
import static org.approvaltests.Approvals.verify;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;
import static org.junit.jupiter.api.Assertions.fail;
public class GlobalTest {
@Test
......@@ -20,7 +15,6 @@ public class GlobalTest {
player.addXp(20);
player.inventory = new ArrayList<>();
player.inventory.add("SWORD");
Affichage affiche = new Affichage();
verify(affiche.afficherJoueur(player));
verify(Display.afficherJoueur(player));
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment