Skip to content

Commit 050fc08

Browse files
🔨 Validation test Professeur
1 parent a0711f6 commit 050fc08

File tree

1 file changed

+22
-3
lines changed

1 file changed

+22
-3
lines changed

src/main/java/fr/umontp/edt/Professeur.java

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
package fr.umontp.edt;
22

3+
import java.text.Normalizer;
34
import java.util.Locale;
5+
import java.util.regex.Pattern;
46

57
/**
68
* <b>Professeur est la classe représentant un professeur au sein de l'emploi du
@@ -19,7 +21,7 @@
1921
* @see RepertoireProfesseur
2022
*
2123
* @author MathieuSoysal
22-
* @version 1.0.0
24+
* @version 1.0.1
2325
*/
2426
public class Professeur {
2527
private String denomination;
@@ -39,12 +41,29 @@ public class Professeur {
3941
denomination = formater(nom, prenom);
4042
}
4143

44+
/**
45+
* @param nomPrenom
46+
*
47+
* @return la variable {@code nomPrenom} formaté.
48+
*
49+
* @see String#toUpperCase(Locale)
50+
* @see Professeur#supprimerAccent(String)
51+
*
52+
* @since 1.0.1
53+
*/
54+
static String formater(String nomPrenom) {
55+
nomPrenom = supprimerAccent(nomPrenom);
56+
return nomPrenom.toUpperCase(Locale.FRANCE).replaceAll("[^A-Z ]", " ");
57+
}
58+
4259
static String formater(String nom, String prenom) {
4360
return formater(nom + " " + prenom);
4461
}
4562

46-
static String formater(String nomPrenom) {
47-
return nomPrenom.toUpperCase(Locale.FRANCE).replaceAll("[^A-Z ]", " ");
63+
private static String supprimerAccent(String str) {
64+
String nfdNormalizedString = Normalizer.normalize(str, Normalizer.Form.NFD);
65+
Pattern pattern = Pattern.compile("\\p{InCombiningDiacriticalMarks}+");
66+
return pattern.matcher(nfdNormalizedString).replaceAll("");
4867
}
4968

5069
/**

0 commit comments

Comments
 (0)