From bd88e54ee2e4dfd470f37df870cdafb13fd1d831 Mon Sep 17 00:00:00 2001 From: lebretonm Date: Wed, 8 Oct 2025 10:47:54 +0200 Subject: [PATCH 1/2] Ajout de Letter.java avec gestion des lettres --- Letter.class | Bin 0 -> 2580 bytes Letter.java | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 50 insertions(+) create mode 100644 Letter.class create mode 100644 Letter.java diff --git a/Letter.class b/Letter.class new file mode 100644 index 0000000000000000000000000000000000000000..c246e38ff2a5ff46f8e156be9567f35d2beead98 GIT binary patch literal 2580 zcmX^0Z`VEs1_pD6nOqFY3^wcxwp9DIB_vJGq`{V zS1txO26rw74+c+e1}_G0P6i(aUk(O8E(U*w0Fcf=kZ=$OLokRA;bsVB2;*ijX9x!o z5$p_++zgToF(8v-L993-1_p*Cc7|jQh7>LaIfhgakp?2t*%>kz8Mw;xi&8@J-7@o1 z7#W0ovJ%S@^>Y&Q()EK&iZb)ktr;2kic@n^lS@)ld{RqFQi~WF7@Zjzc$4#sic*tH zU}F3bouwt2Ir_ed1=frVoWYstd5I;ZMX8JomZ-8e5H8pn&%Bb<^wc72Bq8UF#G=IH zlGGw=J8MP;{>(fyyF?*s!FD+o6(v^sWEPiLGcxF46GyfS)nGQ8%)HDJJ4OaE4Twgt zd!XKS)(m50U~$e*No8c<_sPsl^()OyN-YXWOv*`RWZ=mG2Zd)|cz#g|BLlMrNHuS8 zNn&!gZ(;#dk!VV0aY0UEr89C!6|*yBGBU8_CT8Y=ERM#s8Dtb!aDHh~a;jS<$TDt7 z80&$ehKE6)!Gw`P5X9C82Y^RnafWYV0S|))gC-+`FhT+zGCT}A47xlFDh#ST3~CJO z>fLz(d z!_W=VE8vu$Us7CBlvv=KT9T2UQq0fB(8Iyd%frye(9g)g1_?Jt29}c4;u28E8SpR| zGnnu&n1RAj031}{IQLJ=N=+_dWDo)ifrHhvB(*59B)^D}0ZAPsZ7?#h<)r4Nmt=q= z-jk7mEjc5x$gzZxfknep(-{^!V3VP#n~{ONEHS4v)jtgs>7JTMu?|&X4GRjeHh4m1 zWRTEsMph1&v1Vl8ML5?tv4D|*xuCR!k--8vHA8%coVlPP$Yw%?P`z4NT#}m0$iSQr zG83BPGV}EViZb&`f=h~06LaBCMipjcU@rhE%E@D75Jh$iB=oF7>6Ils! zMh5oGV%OY)l1gy+MlmvQq=HgKaB2x7gP;b~;owLLP6cIqq+kH6;mCx?ofwL8Se#lj zGO%YP7W<`EfZ{9 zvn0bgKd-nXF|VW;Ek2=^Af+Fu2o{&HGfV>IgsF@SD&T|yc4cN>S$=jZv~Y*m=a!gU zl3!HG&M+O6XY%v2OA8noW+3|(stJjTjghq!`#37#KJhSQuCt_!-z3 zq!>6E8=dVK8M7Ww2!sW3XqCU~p!TWC&sqVu)anWiVx6 zVBle3`OCn<$Y>?>i-DDa5mdB79X$i;=qQk*b}|SvGR$P)1Gzp_5VH(2}21$l^aO^TNBrq^CBmw~07m+jo literal 0 HcmV?d00001 diff --git a/Letter.java b/Letter.java new file mode 100644 index 0000000..6b0eacd --- /dev/null +++ b/Letter.java @@ -0,0 +1,50 @@ +import java.util.*; +public class Letter{ + public String wordToFind; + public char selectedLetter; + public Map correctLetter = new HashMap<>();//map qui contient les lettre qui sont dans le mot et a quelle rang dans le mot il se trouve + public ArrayList incorrectLetter= new ArrayList<>();//list qui contient les lettre qui ne sont pas dans le mot + + public Letter(String mot, char lettre) { + this.wordToFind = mot; + this.selectedLetter = lettre; +} + + + /*regarde si la lettre donné est dans le mot si c'est le cas on ajoute + dans un tableau la lettre et son emplacement dans le mot */ + public void letterInWord(){ + boolean found=false;//incremente si la lettre est dans le mot + for (int i=0;i<=this.wordToFind.length()-1;i++){ + if(this.selectedLetter==this.wordToFind.charAt(i)){ + this.correctLetter.put(i,this.selectedLetter); + found=true; + } + if(!found){ + this.incorrectLetter.add(this.selectedLetter); + } + + } + } + + + + + public void displayCorrectLetters() { + if (correctLetter.isEmpty()) { + System.out.println("Aucune lettre correcte trouvée."); + } else { + for (Map.Entry entry : correctLetter.entrySet()) { + System.out.println("Lettre '" + entry.getValue() + "' trouvée à la position " + entry.getKey()); + } + } + } + + public static void main(String[] args) { + Letter lettre = new Letter("test", 't'); + lettre.letterInWord(); + lettre.displayCorrectLetters(); + + } + +} \ No newline at end of file From ca6cabe021f2f84df4f3f0aed08e19a701c0bd1c Mon Sep 17 00:00:00 2001 From: lebretonm Date: Wed, 8 Oct 2025 10:57:57 +0200 Subject: [PATCH 2/2] Ajout de Letter.java avec gestion des lettres --- HangedManagement.java | 0 Letter.class | Bin 2580 -> 2471 bytes Letter.java | 19 +++++++++---------- 3 files changed, 9 insertions(+), 10 deletions(-) create mode 100644 HangedManagement.java diff --git a/HangedManagement.java b/HangedManagement.java new file mode 100644 index 0000000..e69de29 diff --git a/Letter.class b/Letter.class index c246e38ff2a5ff46f8e156be9567f35d2beead98..ef39f286dde9ecd70a822e0aa1d81330cc2985a4 100644 GIT binary patch delta 1041 zcmbOtvRt_S)W2Q(7#JAL876ZvC^A^GGgxskFfmwiGRQDkvoqLmF|a~7wjdEZE(UuB z2N2=N#o)x?%*Eis;L6S5#^4T8=K*4Qax!=^cyloLa54BY_<==sb3Yd>)1ZhC&{OB8Flfh7yKSc7`$@hH{3A$?uqy<=Gi3c^Ik~ba)u58EV)W zYIzvy80vW#8W>7>7#bOxCTlS3dp9#QfsAV5VQ6J&Vq_3-%Fiz;E-6YZ@J%hr$WJNe zXJcsNU})!I=wRq%WMK12Eh$MYVq{<`Nd>u58)UdXg8>hN5rgsOMa-g%lNDI?CU0j6 zob1QCgSm^Ldom|m9a|4bd;jEKHciHflee=iW1KWOj@`#yhCz{mfq|KU5#&(@1_nk3 z6$VuXMg}zo1_mYubp}RID8Ttz3@i+c4B8Aj42%rA3=9k&49pBn3=9kklYg?y*KY*t z*JEH{5My9vU|?WpU}0ck;AdcEkYeCqkZ0gzU}Vr|Fo5cv#K6qJ0y2Zymf22LYYPL% zHU>_Xl*J5|(jboPHU_Q*4B}c_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Fo^DEkc$+O7bw}zpx~pujX_a+ z8-o(a21ane2r;lQFfiyc@G$5x2r%d~h%gv3Ff&+zQ-L)@Gy?;J5Cao~B!d@26dNbQ XWQJ)BQy3%};=vKj$dJIm$dCvC1hK^6 diff --git a/Letter.java b/Letter.java index 6b0eacd..b47aca7 100644 --- a/Letter.java +++ b/Letter.java @@ -1,34 +1,33 @@ import java.util.*; public class Letter{ public String wordToFind; - public char selectedLetter; public Map correctLetter = new HashMap<>();//map qui contient les lettre qui sont dans le mot et a quelle rang dans le mot il se trouve public ArrayList incorrectLetter= new ArrayList<>();//list qui contient les lettre qui ne sont pas dans le mot - public Letter(String mot, char lettre) { + public Letter(String mot) { this.wordToFind = mot; - this.selectedLetter = lettre; } /*regarde si la lettre donné est dans le mot si c'est le cas on ajoute dans un tableau la lettre et son emplacement dans le mot */ - public void letterInWord(){ + public void letterInWord(char selectedLetter ){ boolean found=false;//incremente si la lettre est dans le mot for (int i=0;i<=this.wordToFind.length()-1;i++){ - if(this.selectedLetter==this.wordToFind.charAt(i)){ - this.correctLetter.put(i,this.selectedLetter); + if(selectedLetter==this.wordToFind.charAt(i)){ + this.correctLetter.put(i,selectedLetter); found=true; } if(!found){ - this.incorrectLetter.add(this.selectedLetter); + this.incorrectLetter.add(selectedLetter); } } } - +/*juste ppour afffichage pas important a supprimer +*/ public void displayCorrectLetters() { if (correctLetter.isEmpty()) { @@ -41,8 +40,8 @@ public class Letter{ } public static void main(String[] args) { - Letter lettre = new Letter("test", 't'); - lettre.letterInWord(); + Letter lettre = new Letter("test"); + lettre.letterInWord('t'); lettre.displayCorrectLetters(); }