diff --git a/Makefile b/Makefile index 6301970..8833e5c 100644 --- a/Makefile +++ b/Makefile @@ -21,7 +21,7 @@ CLASSFILES = Pendu.class \ $(OUT)Pendu.class : $(IN)Pendu.java $(OUT)Partie.class $(OUT)Fenetre.class $(JC) $(JCFLAGS) $< -$(OUT)Partie.class : $(IN)Partie.java +$(OUT)Partie.class : $(IN)Partie.java $(OUT)Mots.class $(JC) $(JCFLAGS) $< $(OUT)Fenetre.class : $(IN)Fenetre.java $(OUT)Partie.class $(OUT)Dessin.class @@ -30,6 +30,9 @@ $(OUT)Fenetre.class : $(IN)Fenetre.java $(OUT)Partie.class $(OUT)Dessin.class $(OUT)Dessin.class : $(IN)Dessin.java $(JC) $(JCFLAGS) $< +$(OUT)Mots.class : $(IN)Mots.java + $(JC) $(JCFLAGS) $< + # Commandes Pendu : $(OUT)Pendu.class diff --git a/src/Mots.java b/src/Mots.java new file mode 100644 index 0000000..233e9fc --- /dev/null +++ b/src/Mots.java @@ -0,0 +1,58 @@ + +/** +* La classe Mots +* +* @version 1.0 +* @author Aurélien +* Date : 08-10-25 +* Licence : +*/ +public final class Mots { + //Attributs + public static final short dictionarysize = 32 ; + public static final String[] dictionary = { + "Magnifique", + "Etoile", + "Voyage", + "Biscuit", + "Refrigerateur", + "Courage", + "Avion", + "Explorateur", + "Montagne", + "Philosophie", + "Lumiere", + "Ethernet", + "Architecture", + "Ocean", + "Liberte", + "Aventure", + "Cerise", + "Harmonieux", + "Informatique", + "Pluie", + "Equilibriste", + "Papillon", + "Saisons", + "Liberte", + "Alphabet", + "Musique", + "Translucent", + "Passion", + "Etreindre", + "Poetique", + "Serenite", + "Révolution" + }; + + //Constructeur + private Mots() { //N'a pas pour but d'être instanciée + throw new UnsupportedOperationException("The \"Fichier\" class cannot be instanced !"); + } + //Méthodes + + //Affichage + public String toString() { + return "" ; + } +} diff --git a/src/Partie.java b/src/Partie.java index c96cdf5..0052a7a 100644 --- a/src/Partie.java +++ b/src/Partie.java @@ -1,8 +1,9 @@ +import java.util.Random; /** * La classe Partie * -* @version 0.1 +* @version 0.2 * @author Aurélien * Date : 08-10-25 * Licence : @@ -81,10 +82,15 @@ public class Partie { } } - + /** + * Génère un mot à partir d'un grand dictionnaire (enfin en principe). + * + * @return le mot généré. + */ private char[] generateSecretWord() { - char[] word = {'D','A','M','I','E','N'}; - //À implémenter plus tard + Random random = new Random(); + byte grain = (byte) random.nextInt(Mots.dictionarysize); + char[] word = Mots.dictionary[grain].toUpperCase().toCharArray(); return word ; } @@ -105,7 +111,7 @@ public class Partie { //Tests public static void main(String[] args){ - char[] test = {'E','O','M','I','E','D','A','Z','N'}; + char[] test = {'E','O','M','I','E','D','A','Z','N','L','C','R','P','H','T','S'}; byte size = (byte) test.length ; boolean status ; @@ -124,5 +130,6 @@ public class Partie { System.out.println(""); //Lisibilité //System.out.println("Lettres : " + game.entriesletters); } + System.out.println("Essais restants : " + game.getRemainingTry()); } }