1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127
| package tp1mts;
import java.io.*;
import java.util.Scanner;
public class Tp1Mts {
public static void main(String[] args) {
affichageFg();
}
static void affichageFg() {// Affichage du fichier Fg sans espaces,accents ou symboles
try {
BufferedReader grille = new BufferedReader(new FileReader("grille.txt"));
String ligneA;
int nbLignes = 0;
ligneA = grille.readLine();
while (ligneA != null) {
ligneA = grille.readLine();
nbLignes++;
}
System.out.println("Rappel il y a " + nbLignes + " ligne(s) dans votre fichier grille");
grille.close();
grille = new BufferedReader(new FileReader("grille.txt"));
String[] tabA = new String[nbLignes];
for (int i = 0; i < tabA.length; i++) {
tabA[i] = grille.readLine();
}
System.out.println("Voici le contenu de votre grille.txt: ");
for (String a : tabA) {
System.out.println(a.trim().toLowerCase().replaceAll("[-+.^:,/~!@#$%$%^&*()_]", ""));
}
} catch (FileNotFoundException ex) {
System.out.println("Je ne trouve pas le fichier");
} catch (IOException e) {
System.out.println("Je trouve une erreur dans ton fichier IOException");
}
affichageFm();// debut de lexecution mots.txt
}
static void affichageFm() {
try {
BufferedReader mots = new BufferedReader(new FileReader("mots.txt"));
String ligneB;
int nbLignesB = 0;
ligneB = mots.readLine();
while (ligneB != null) {
ligneB = mots.readLine();
nbLignesB++;
}
System.out.println("Rappel il y a " + nbLignesB + " ligne(s) dans votre fichier mots");
mots.close();
mots = new BufferedReader(new FileReader("mots.txt"));
String[] tabB = new String[nbLignesB];
for (int i = 0; i < tabB.length; i++) {
tabB[i] = mots.readLine();
}
System.out.println("Voici le contenu de votre mots.txt: ");
for (String b : tabB) {
System.out.println(b.trim().toLowerCase().replaceAll("[-+.^:,/~!@#$%$%^&*()_]", ""));
}
} catch (FileNotFoundException ex) {
System.out.println("Je ne trouve pas le fichier");
} catch (IOException e) {
System.out.println("Je trouve une erreur dans ton fichier IOException");
}
affichageExec();// affichage des demarches
}
static void affichageExec() {// affichage lors de lexecution
System.out.println("Démarrage");
System.out.println("");
System.out.println("Chargement de la grille
ok");
System.out.println("");
System.out.println("Chargement de la liste de mots
ok");
System.out.println("");
System.out.println("Validation de la liste de mots
ok");
System.out.println("");
System.out.println("Recherche des intrus
ok");
System.out.println("");
System.out.println("Les intrus trouvés sont dans le fichier intrus.txt et vonts aparaitre ici:");
System.out.println("");
System.out.println("Traitement terminé.");
FinExec();// demande d'arret du programme
}
static void FinExec() {//Demander a l'utilisateur s'il veut recommencer
Scanner clavier = new Scanner(System.in);
System.out.println("Voulez vous recommnecer l'execution du programme?(oui ou non)");
boolean refus;
String decision1;
char decision_1;
decision1 = clavier.nextLine().toLowerCase();
decision_1 = decision1.charAt(0);
switch (decision1) {
case "non":
System.out.println("Le programme s'arrête");
System.exit(0);
case "oui":
System.out.println("");
System.out.println("Le programme recommence------>");
System.out.println("");
affichageFg();
refus = true;
break;
default:
System.out.println("Erreur, fin du programme");
break;
}
}
} |
Partager