From 9593ca5fabdcdfe3eea927e43ca59583e3b70e9a Mon Sep 17 00:00:00 2001 From: "emile.malcuit" Date: Fri, 26 Sep 2025 11:20:29 +0200 Subject: [PATCH] =?UTF-8?q?test=20unitaire=2013=20carract=C3=A8re=20isbn?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 1 + .../bibliotheque/Contrôle/LivreValide.java | 16 ++++++- .../bibliotheque/LivreValideTest.java | 48 ++++++++++++++++--- 3 files changed, 57 insertions(+), 8 deletions(-) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..b83d222 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/target/ diff --git a/src/main/java/com/mycompany/bibliotheque/Contrôle/LivreValide.java b/src/main/java/com/mycompany/bibliotheque/Contrôle/LivreValide.java index 08550ee..bdec9cf 100644 --- a/src/main/java/com/mycompany/bibliotheque/Contrôle/LivreValide.java +++ b/src/main/java/com/mycompany/bibliotheque/Contrôle/LivreValide.java @@ -12,8 +12,20 @@ public class LivreValide { // 1. ISBN : exactement 13 chiffres public static boolean isValidIsbn(String isbn) { // TODO Emile: implémenter la validation - //Init branch - return false; + boolean valide = true; + if(isbn.length() == 13){ + int i = 0; + while (i < 13 && valide) { + if(!Character.isDigit(isbn.charAt(i))){ + valide = false; + }else{ + i++; + } + } + }else{ + valide = false; + } + return valide; } // 2. Titre : pas de balises HTML/JS (