Portfolio Code | Clement Colmerauer
Repositories
Site
Kata refactoring
Code
Commits
Branches
Tags
Search
Tree:
023ff0d
Branches
Tags
master
Kata refactoring
src
main
java
re
forestier
edu
rpg
Affichage.java
Ajout assertion non null pour méthode, économie sur test unitaire
Clement Colmerauer
commited
023ff0d
at 2024-12-13 12:29:53
Affichage.java
Blame
History
Raw
package re.forestier.edu.rpg; import java.io.File; import java.io.IOException; import java.io.FileWriter; public class Affichage { public static void afficherJoueur(Player player) { assert player != null : "Player must be non null"; System.out.println(player.toString()); } public static void playerToMarkDown(Player p) { assert p != null : "Player must be non null"; try { File playerFile = new File("./"+p.getAvatarName()+".md"); FileWriter myWriter = new FileWriter(playerFile); myWriter.write(p.toMarkDown()); myWriter.close(); } catch (IOException e) { System.err.println("An error occurred."); e.printStackTrace(); } } public static void playerToMarkDown(Player p, String path) { assert p != null : "Player must be non null"; assert path != null : "Path must be non null"; try { File playerFile = new File(path+p.getAvatarName()+".md"); FileWriter myWriter = new FileWriter(playerFile); myWriter.write(p.toMarkDown()); myWriter.close(); } catch (IOException e) { System.err.println("An error occurred."); e.printStackTrace(); } } }