Compare commits

...

9 Commits

Author SHA1 Message Date
e6e0d4cf71 Correctif noms 2025-10-08 16:14:39 +02:00
ffbe1e232e Retirer Console 2025-10-08 16:09:04 +02:00
2a8eac0720 Gestion de partie (sans génération) 2025-10-08 16:07:03 +02:00
d7ace2c8be Super Makefile 2025-10-08 11:01:36 +02:00
56009640f5 Merge pull request 'Readme' (#2) from dick into master
Reviewed-on: dick/TD3_DEV51_dick_amary#2
2025-10-08 10:42:21 +02:00
80264f552f Merge branch 'master' into dick 2025-10-08 10:39:58 +02:00
258aab00f3 Merge pull request 'Base' (#1) from amary into master
Reviewed-on: dick/TD3_DEV51_dick_amary#1
2025-10-08 10:34:58 +02:00
5e8e4a1183 Readme 2025-10-08 10:29:37 +02:00
1741908a9d Base 2025-10-08 10:26:19 +02:00
11 changed files with 311 additions and 0 deletions

1
Diagramme.mdj Normal file

File diff suppressed because one or more lines are too long

48
Makefile Normal file
View File

@@ -0,0 +1,48 @@
# Projet Pendu : fichier Makefile
# Compatibilité : Linux
# Règle par défaut
all : Pendu
# Dossiers
IN = src/
OUT = bin/
# Mots-clés
JC = javac
JCFLAGS = -encoding UTF-8 -implicit:none -cp $(OUT) -d $(OUT)
CLASSFILES = Pendu.class \
Partie.class \
Fenetre.class \
Dessin.class
# Dépendances
$(OUT)Pendu.class : $(IN)Pendu.java $(OUT)Partie.class $(OUT)Fenetre.class
$(JC) $(JCFLAGS) $<
$(OUT)Partie.class : $(IN)Partie.java
$(JC) $(JCFLAGS) $<
$(OUT)Fenetre.class : $(IN)Fenetre.java $(OUT)Partie.class $(OUT)Dessin.class
$(JC) $(JCFLAGS) $<
$(OUT)Dessin.class : $(IN)Dessin.java
$(JC) $(JCFLAGS) $<
# Commandes
Pendu : $(OUT)Pendu.class
jar : $(OUT)Pendu.class
jar -cfe Pendu.jar Pendu -C $(OUT) .
clean :
-rm -f $(OUT)*.class
-rm -f Pendu.jar
help : #(à implémenter plus tard)
# Buts factices
.PHONY : all clean #(pour les cibles qui sont des commandes)
# Bug : gestion des chemins dans jar ?

View File

@@ -0,0 +1,23 @@
/**
* La classe <code>Class</code>
*
* @version
* @author
* Date :
* Licence :
*/
public class Class {
//Attributs
//Constructeur
public Class() {
}
//Méthodes
//Affichage
public String toString() {
return "" ;
}
}

View File

@@ -0,0 +1,23 @@
import javax.swing.*;
import java.awt.event.*;
/**
* La classe <code>Event</code>
*
* @version
* @author
* Date :
* Licence :
*/
public class Event implements ActionListener {
// Attributs
// Constructeur de l'évennement
public Event() {
}
// Action de l'évennement
public void actionPerformed(ActionEvent event){
}
}

View File

@@ -0,0 +1,14 @@
/**
* L'interface <code>Interface</code>
*
* @version
* @author
* Date :
* Licence :
*/
public interface Interface {
//Méthodes
public void Action() ;
}

14
Modèles/Modèle Main.txt Normal file
View File

@@ -0,0 +1,14 @@
/**
* La classe <code>Main</code>
*
* @version
* @author
* Date :
* Licence :
*/
public class Main {
public static void main(String[] args){
}
}

0
README.md Normal file
View File

23
src/Dessin.java Normal file
View File

@@ -0,0 +1,23 @@
/**
* La classe <code>Dessin</code>
*
* @version
* @author
* Date :
* Licence :
*/
public class Dessin {
//Attributs
//Constructeur
public Dessin() {
}
//Méthodes
//Affichage
public String toString() {
return "" ;
}
}

23
src/Fenetre.java Normal file
View File

@@ -0,0 +1,23 @@
/**
* La classe <code>Fenetre</code>
*
* @version
* @author
* Date :
* Licence :
*/
public class Fenetre {
//Attributs
//Constructeur
public Fenetre() {
}
//Méthodes
//Affichage
public String toString() {
return "" ;
}
}

128
src/Partie.java Normal file
View File

@@ -0,0 +1,128 @@
/**
* La classe <code>Partie</code>
*
* @version 0.1
* @author Aurélien
* Date : 08-10-25
* Licence :
*/
public class Partie {
//Contantes
private static final byte REMAININGTRY = 11 ;
private static final byte CARACTERCODESHIFT = 65 ; //Décalage ASCI > 'A'
//Attributs
private char[] secretword ;
private byte wordsize ;
private boolean[] foundletters ;
private boolean[] entriesletters = new boolean[26] ; //Pseudo Alphabée
private byte remainingtry = REMAININGTRY ;
//Constructeur
public Partie() {
this.secretword = generateSecretWord() ;
this.wordsize = (byte) secretword.length ;
this.foundletters = new boolean[wordsize] ;
}
//Méthodes
public char[] getSecretWord() {
return this.secretword ;
}
public boolean[] getFoundLetters() {
return this.foundletters ;
}
public byte getRemainingTry() {
return this.remainingtry ;
}
/**
* Vérifie l'état de la partie en cours.
*
* @return true si le jeu est fini.
*/
public boolean gameIsEnding() {
if(this.remainingtry <= 0){
return true ;
}else if(wordIsFound()){
return true ;
}else{
return false ;
}
}
/**
* Vérifie si la lettre reçu n'a pas déjà été joué puis, met à jour le tableau "entriesletters" et
* "foundletters" le cas échéant.
*
* @return true si la lettre était déjà présente.
*/
public boolean isAlreadyEntries(char letter) {
short caractercode = (short) letter ; //Récupération du code du caractère
if(this.entriesletters[caractercode-CARACTERCODESHIFT]){
this.remainingtry-- ; //Décrément des essais
return true ;
}else{
boolean isfind = false ;
for(byte i = 0 ; i < this.wordsize ; i++){ //Parcours du "secretword"
if(this.secretword[i] == letter){
this.foundletters[i] = true ;
isfind = true ;
}
}
if(isfind == false){
this.remainingtry-- ; //Décrément des essais
}
this.entriesletters[caractercode-CARACTERCODESHIFT] = true ; //Ajout au tableau des lettres jouées
return false ;
}
}
private char[] generateSecretWord() {
char[] word = {'D','A','M','I','E','N'};
//À implémenter plus tard
return word ;
}
private boolean wordIsFound() {
for(byte i = 0 ; i < this.wordsize ; i++){ //Parcours du "secretword"
if(!this.foundletters[i]){ //Si une lettre n'est pas trouvé
return false ;
}
}
return true ;
}
//Affichage
public String toString() {
return "" ;
}
//Tests
public static void main(String[] args){
char[] test = {'E','O','M','I','E','D','A','Z','N'};
byte size = (byte) test.length ;
boolean status ;
Partie game = new Partie();
System.out.println("Trick > " + String.valueOf(game.secretword) + "\n");
for(byte i = 0 ; i < size && !game.gameIsEnding() ; i++){
System.out.println("Essais restants : " + game.getRemainingTry());
status = game.isAlreadyEntries(test[i]);
for(byte l = 0 ; l < game.wordsize ; l++){ //Parcours du "secretword"
if(game.foundletters[l] == true){
System.out.print(game.getSecretWord()[l] + " ");
}else{
System.out.print("_ ");
}
}
System.out.println(""); //Lisibilité
//System.out.println("Lettres : " + game.entriesletters);
}
}
}

14
src/Pendu.java Normal file
View File

@@ -0,0 +1,14 @@
/**
* La classe <code>Pendu</code>
*
* @version
* @author
* Date :
* Licence :
*/
public class Pendu {
public static void main(String[] args){
}
}