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
|
public class Main
{
final static String[] lettresAleatoires =
{
"R", "B", "O", "V", "J", "F", "I", "N"
};
static String oui = "oui";
static String lettresAuHasard = "";
static String jouerPartie = "";
static String CombinaisonEntree = "";
static String chaine = "";
static int[] tableau = new int [4];
static int[] tableau2 = new int [4];
static int aleatoire;
static int sortie;
static BufferedReader r = new BufferedReader(new InputStreamReader(System.in));
static Random generateur = new Random();
static String chaineEntree;
char tableauChaine;
static char[] k = new char [4];
static char[] l = new char [4];
static int essai = 1;
public static void main(String[] args) throws IOException
{
afficherRegles();
demanderSiExecutionDuJeu();
for (int i = 0; i < 3; i++)
{
genererLettres();
}
demanderCombinaison();
determinerSiExact();
}
private static void afficherRegles()
{
System.out.println("Le programme génère automatiquement une suite de\n"
+ "caractères de quatre lettres que l'utilisateur\ntentra de "
+ "deviner en un maximum de dix essais.\nS'il n'a pas réussi lors"
+ " des essais alloués ou\ns'il quitte le jeu, la partie est "
+ "perdue.\nBonne chance! ");
System.out.println("-------------------------------------------------");
}
private static void demanderSiExecutionDuJeu() throws IOException
{
System.out.println("Voulez-vous jouer une partie? (répondre oui)");
jouerPartie = r.readLine();
if (jouerPartie.equalsIgnoreCase(oui))
{
genererLettres();
}
else
{
System.exit(sortie);
}
}
private static void genererLettres()
{
aleatoire = generateur.nextInt(8);
chaine = "" + lettresAleatoires[aleatoire];
k = chaine.toCharArray();
System.out.println(k);
}
private static void demanderCombinaison() throws IOException
{
System.out.println("Entrez votre combinaison pour l'essai" + essai +
" <enter> pour arrêter");
CombinaisonEntree = r.readLine();
l = CombinaisonEntree.toCharArray();
}
private static void determinerSiExact()
{
}
} |
Partager