33 lines
987 B
Java
33 lines
987 B
Java
|
package question2;
|
||
|
|
||
|
import java.util.ArrayList;
|
||
|
|
||
|
public class Comparateur {
|
||
|
|
||
|
public static void main(String[] arg) {
|
||
|
int TAILLE_EXTRAIT = 50;
|
||
|
String texteClair = Utilitaire.lireTexte("texte2.txt");
|
||
|
System.out.println("début du texte original : "
|
||
|
+ texteClair.substring(0, Math.min(50, texteClair.length())));
|
||
|
|
||
|
ArrayList<AlgoCodage> algoAComparer = new ArrayList<AlgoCodage>();
|
||
|
algoAComparer.add(new Cesar(3));
|
||
|
algoAComparer.add(new Morse());
|
||
|
algoAComparer.add(new Cesar(10));
|
||
|
|
||
|
String encodee = "";
|
||
|
for (AlgoCodage algo : algoAComparer) {
|
||
|
System.out.println("algorithme : " + algo.getNom());
|
||
|
encodee = algo.encode(texteClair);
|
||
|
System.out.println("\tencodage : "
|
||
|
+ "\t résultat : "
|
||
|
+ encodee.substring(0, Math.min(50, encodee.length())));
|
||
|
|
||
|
String decodee = algo.decode(encodee);
|
||
|
System.out.println("\tdécodage : "
|
||
|
+ "\t résultat : "
|
||
|
+ decodee.substring(0, Math.min(50, decodee.length())));
|
||
|
}
|
||
|
}
|
||
|
}
|