package utils; import java.util.Map; import java.util.List; import java.util.Arrays; import java.util.stream.Collectors; import java.util.Scanner; import java.util.function.Function; import java.util.function.BiFunction; public class Utils { public static Map ROMAINS = Map.of( "I", 1, "II", 2, "III", 3, "IV", 4, "V", 5, "VI", 6, "VII", 7, "VIII", 8, "IX", 9, "X", 10 ); public static final char[] ALPHABET = new char[] { 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z' }; public static String[] CESAR_DATA_CLEAR = new String[] { "quitte moi quittons nous juste un peu trop longtemps", "pour que nous ressentions le bonheur d etre triste" }; public static int[] CESAR_DATA_KEYS = new int[] { 7, 9 }; public static String[] CESAR_DATA_CRYPT = new String[] { "xbpaal tvp xbpaavuz uvbz qbzal bu wlb ayvw svunaltwz", "yxda zdn wxdb anbbnwcrxwb un kxwqnda m ncan carbcn" }; public static int[] TEST_SOMME2 = new int[] { 0, 3, 6, 3, 7, 25, 7, 3, 25, }; public static void testSomme2(BiFunction func) { for (int i=0; i i+"") .collect(Collectors.joining(" ")); System.out.println(str); } System.out.print(' '); } public static int lireEntier() { try (Scanner reader = new Scanner(System.in)) { System.out.println("Saisir un entier: "); return reader.nextInt(); } } public static String lireChaine() { try (Scanner reader = new Scanner(System.in)) { System.out.println("Saisir une valeur et valider: "); return reader.nextLine(); } } public static int position(char c) { for (int i = 0; i func, boolean chiffre) { for (int i = 0; i func) { testPalindrome(func, "palindrome", false); for (String pal : List.of("elle", "kayak", "serres", "essayasse")) { testPalindrome(func, pal, true); } } public static void testPalindrome(Function func, String mot, boolean result) { boolean val = func.apply(mot.toCharArray()); afficher(mot, result == val ? "OK" : "ERREUR"); } public static void testRomains(Function func) { for (Map.Entry entry : ROMAINS.entrySet()) { String rom = entry.getKey(); int val = entry.getValue(); int res = func.apply(rom.toCharArray()); afficher(rom, " -> ", res); if (res == val) { afficher("Succés"); } else { afficher("Attendu:", val); } } } }