From 00fec48636ce5496b63cd266d9e854a6601d90e7 Mon Sep 17 00:00:00 2001 From: dick Date: Tue, 30 Apr 2024 15:00:32 +0200 Subject: [PATCH] plusClassesAnonymeEtFinProgramme2 --- AutomatiqueActionListener.class | Bin 0 -> 1657 bytes AutomatiqueActionListener.java | 32 +++++++++ CaseMouseListener.class | Bin 0 -> 2353 bytes CaseMouseListener.java | 37 +++++++++++ FenetreChoix.class | Bin 0 -> 1359 bytes FenetreChoix.java | 31 +++++++++ FenetrePrincipale.class | Bin 0 -> 1143 bytes FenetrePrincipale.java | 25 +++++++ GenerateurSudoku.class | Bin 720 -> 720 bytes GrillePainter.class | Bin 0 -> 1296 bytes GrillePainter.java | 29 ++++++++ GrilleSudokuDessin.class | Bin 1307 -> 1304 bytes Main$1.class | Bin 1113 -> 0 bytes Main.class | Bin 2029 -> 496 bytes Main.java | 87 +----------------------- ManuelActionListener.class | Bin 0 -> 822 bytes ManuelActionListener.java | 23 +++++++ OuvertureFichier.class | Bin 1311 -> 1181 bytes Reinitialiser.class | Bin 720 -> 720 bytes ReinitialiserActionListener.class | Bin 0 -> 552 bytes ReinitialiserActionListener.java | 20 ++++++ Resolveur.class | Bin 855 -> 855 bytes SaisieGrille$1.class | Bin 2040 -> 0 bytes SaisieGrille.class | Bin 1935 -> 2061 bytes SaisieGrille.java | 107 ++++++++++++++++-------------- 25 files changed, 258 insertions(+), 133 deletions(-) create mode 100644 AutomatiqueActionListener.class create mode 100644 AutomatiqueActionListener.java create mode 100644 CaseMouseListener.class create mode 100644 CaseMouseListener.java create mode 100644 FenetreChoix.class create mode 100644 FenetreChoix.java create mode 100644 FenetrePrincipale.class create mode 100644 FenetrePrincipale.java create mode 100644 GrillePainter.class create mode 100644 GrillePainter.java delete mode 100644 Main$1.class create mode 100644 ManuelActionListener.class create mode 100644 ManuelActionListener.java create mode 100644 ReinitialiserActionListener.class create mode 100644 ReinitialiserActionListener.java delete mode 100644 SaisieGrille$1.class diff --git a/AutomatiqueActionListener.class b/AutomatiqueActionListener.class new file mode 100644 index 0000000000000000000000000000000000000000..c66d6db6b425e357e7729b4e2c6e1ea9bca79ddd GIT binary patch literal 1657 zcmaJ>TUQ%Z6#h;iOfnAlo2Z3JOKUM|3rU* z;+rm|tah!w@aBKg<(^4cD_HblcJ|rXmv4W2pY!M6FJA+gz;`CPkx8QqS4~{Qu!-xq zk;ePTrjRo+f}18CMorwpSdt=u_L&C;@+K@~B5}KmY#*8U7~?5S82H4%rv~man9iP( z&u4vJ5ez-c&-ejm)KF7L&qJ<57!Ekkn2WgNfe8H?KQxkZWD7A)jDnjP7xQFUaiJ=fqT?Nr`}VCD?)2t77rzNRhc2z za5V~wcEpRWL_^-%u!#@@Uq(Ci6~k~$Xk1l#2WnsBYpm5^&eHW${*i%i=o&98+Vv`f zwcyb(3oh4M5cVG$DX-_Kt?xYdO0LkuwZKLo^~p3qyAZf>R27%FZ#Vd#x6)v$rzmjO zEy_Sl8u*ss`WyXShK(MD|Mx?N9?x#j8%JLvdK~CMOpxA>w@D7rX@t%R`ZY&hfQ{Vz z1BqYh#PANuHZ+k;qZua2x5)Y~-mAy`5?g`wk>8OxLDMOkSAIjXtK|g7DN-||r%3;Z z+oVn;`;r;a1G6$=yn^-g1zPW>2hz=>Cun1R#!IvVr|9?zY1Y+AN>o1)*B?hK>FqGk zN!6oHdI)(h2C0v0q}`$p#>w*@;hHC8OSnSoF+`I3LE_zzvkw>SU* literal 0 HcmV?d00001 diff --git a/AutomatiqueActionListener.java b/AutomatiqueActionListener.java new file mode 100644 index 0000000..6164e25 --- /dev/null +++ b/AutomatiqueActionListener.java @@ -0,0 +1,32 @@ + +import javax.swing.*; +import java.awt.event.*; + + +public class AutomatiqueActionListener implements ActionListener { + private JFrame choixFrame; + + public AutomatiqueActionListener(JFrame choixFrame) { + this.choixFrame = choixFrame; + } + + @Override + public void actionPerformed(ActionEvent e) { + choixFrame.dispose(); + + int[][] grille = GenerateurSudoku.genererGrille(); + System.out.println("Grille Sudoku générée avec succès."); + + long startTime = System.nanoTime(); + if (Resolveur.resoudreSudoku(grille)) { + long endTime = System.nanoTime(); + long duration = (endTime - startTime) / 1000000; + + FenetrePrincipale fenetrePrincipale = new FenetrePrincipale(); + fenetrePrincipale.afficher(true, grille); + JOptionPane.showMessageDialog(null, "Grille résolue avec succès en " + duration + " millisecondes !"); + } else { + JOptionPane.showMessageDialog(null, "Impossible de résoudre la grille."); + } + } +} diff --git a/CaseMouseListener.class b/CaseMouseListener.class new file mode 100644 index 0000000000000000000000000000000000000000..501b09ae19d70bcaa98979f5c048be021abd02ea GIT binary patch literal 2353 zcma)7O>h)N6#jb2W;V-^kbeRR3>t7Z!K|QyCV;|{ki`v&*%*G}UuUWM1KlU1Jd$U%KQvw_8|mbJC7`@Pri&DZaH-TlL# z_r3#g3?C=akD(Uq!Eh1>aVUvrF`{M}HG58p!%7@c;`tW5fEU&5s1nCID8*P3$8kcb zClh!jiC1wdiPOj`%NZrcm6%B2tny82$R%(tf!8$THB2$YU2Y4Dp*3INrf-U~o@rTP zjG_6sX`AvSLwo8;S9+eIDeII3LtEao#rdGRD7-noXpu#)I)N{;mRVdDC5FAJ{1v{! zGkjHM#EP(GW=i?T)pSfH+EI|axID$(FkZuX4bu$Cf)jW}F=48dJz4IHFf4ESQrN;9 zQ8{(&!;Fpr?A7r)W;GOa%wbl?8%oS8aY2cTxTNDUE@@cM@h0BV@wPI*gIR{1ryWQ7 z(&O%wkQJxow>9J41St0+iW*8f1eSD^QDHbdZc9&GGc0bba7zT9;Sxxt7KLR6mN5K{ zTb3wF)3NQ1Tf!LCVCuMnWet{&Dr_ANTpjPBqQk=s!^NyHiWPHd$rFYx3{Utj#S6pb zzF`U9C_3~>ZrYOOrNAfzC1*JpG3G^}IJ!o$4pHVAfo<@Bz-=ZQ(cwcf>)$i=G%^I5JPcTyvv~g>RFi}wZ7Wx?WG-`@dCGJY$G4wU^hAl&kJ>F75dZt}w*p>=AvMl7q zP{~mj*7q_6k#CNxnq?!ZsDa6Ji5mEkC+hop%d9AeHR|$(%$sFf6vQUIg4(hvl~dpC zA#c{Pi1UB=>yfTe-&P5n6A&xi(UCBn%nWTn(l!LI(t+zDEDgTXL*@n_NFu-rL%*u- zmd-O$?2y6I482vpEV7PWU;Zx1~?GQ@LC^LJ~GeR84}>8CLj7bPSrSuv*kI z-L)fKAEgS>PB^0?=IGuq>4?zfl1eWu5FfoN=hckAN`z(3O^3}lL-!7q+pjpQIol27 z847WT&e6InBkNRM$5wYm9n$H=D|AZ68iH?s+#WePHf7aL3731mAoX9c6Ta4{`@L** z80qq(>g3Xw8Co9gifZ5qSDi-Mt3o{`e4m%aChqkA#XYZKRb4ReGYme4ODE7-7MX~K zh_MM?l#aKi;X?wHcj)Z9)Y>`fG%ss$-xoyV=k;vVazuC8B)3a+i3~=8^#!a^U02d4 z0_WCT(O~&P-TDR;)KX-*Wfe>*#x#7yaA3>+8eyYn;=k8nKfRCr^w=@P)P+y87|r*= zAi1BkA<|h6q z(PW(Sj!#FH?we>~ z9X)r^dlTD7R>KKEr)Hz%Htss?&LNlH5VRR_sO_Cb1JUXs7qHgPyET ze2OlL=)raL;toaqh(7#Gyxb=q9uO= 0 && x < panel.getTailleGrille() * panel.getTailleRegion() && y >= 0 && y < panel.getTailleGrille() * panel.getTailleRegion()) { + panel.setLigneSelectionnee(y); + panel.setColonneSelectionnee(x); + System.out.println("Case sélectionnée : (" + panel.getLigneSelectionnee() + ", " + panel.getColonneSelectionnee() + ")"); + if (panel.getGrilleInitiale()[panel.getLigneSelectionnee()][panel.getColonneSelectionnee()] == 0) { + String valeurStr = JOptionPane.showInputDialog(null, "Entrez la valeur pour la cellule sélectionnée :"); + try { + int valeur = Integer.parseInt(valeurStr); + if (panel.validerChiffre(panel.getLigneSelectionnee(), panel.getColonneSelectionnee(), valeur)) { + panel.getGrille()[panel.getLigneSelectionnee()][panel.getColonneSelectionnee()] = valeur; + panel.repaint(); + } else { + JOptionPane.showMessageDialog(null, "Ce chiffre ne respecte pas les contraintes du Sudoku. Veuillez choisir un autre chiffre."); + } + } catch (NumberFormatException ex) { + JOptionPane.showMessageDialog(null, "Saisie invalide. Veuillez entrer un nombre."); + } + } else { + JOptionPane.showMessageDialog(null, "Vous ne pouvez pas modifier la valeur par défaut."); + } + } + } +} diff --git a/FenetreChoix.class b/FenetreChoix.class new file mode 100644 index 0000000000000000000000000000000000000000..dacb40096a5bd47cbff9aa84cf531b07c6ce7c89 GIT binary patch literal 1359 zcmZ`(&sP&y6#gD$GQ%(mNdOrYI$Bx-1Ej4#i`JIJrlKLJL2SC4Bo7!nnWvK(Kvvzj z*MGpSyXX?>sIT@G3 zEe&7E_}d!3miikN>pJF8l#wMBcXU`Ns`yq#nIV14_1*9`!)ShShapuGEzU4eaeZEm z+6^9TI}MLKnzOs>HurhJpw~ncGh0QJAlsIBQ`* z*Kt$c^lXQRclfRod11*D9lrI92Q;RfIhEg#2$c{u_n5|3@*9a~j6D6Z7|y-TD=(+- zqYj-t9wgbPB~mn#gpasK`haf>hBE_ECDDE+e4-+Wn4yTfB5;p|A3EN;=kED!`i~x_ z(`qp+y+5!&o9y8v8^hvz!2>+>$w}(!RCk9SOY+K7`5)xuZ@V0Ry$L!)&AfXD7YC~G z1M0ajjG#bVz(xA<IW1Q|`qMn`XB2!JQELm%* z9&!{iwWgR#57T7M#5iLrD=}uDn2MQ_+Fs6@G0xhil07FiInS^3Fju#`n2+(1Nm(p; zxIl-KA*!^DKr2m$Mw@30CRq!#$QE%5mvI_5Fo_~E*d*KzrqG}@=3)lVF^eNY|Ae!6 TiSu|(EWN=zk+DemMzHiR$VE-d literal 0 HcmV?d00001 diff --git a/FenetreChoix.java b/FenetreChoix.java new file mode 100644 index 0000000..d34c45c --- /dev/null +++ b/FenetreChoix.java @@ -0,0 +1,31 @@ +import javax.swing.*; +import java.awt.*; + + +public class FenetreChoix { + public void afficher() { + JFrame choixFrame = new JFrame("Choix de résolution du Sudoku"); + choixFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + choixFrame.setSize(400, 200); + choixFrame.setLayout(new BorderLayout()); + choixFrame.setLocationRelativeTo(null); + + JLabel label = new JLabel("Choisissez le mode de résolution du Sudoku :"); + label.setHorizontalAlignment(JLabel.CENTER); + + JButton automatiqueButton = new JButton("Automatique"); + JButton manuelButton = new JButton("Manuel"); + + JPanel boutonsPanel = new JPanel(); + boutonsPanel.setLayout(new FlowLayout()); + boutonsPanel.add(automatiqueButton); + boutonsPanel.add(manuelButton); + + choixFrame.add(label, BorderLayout.NORTH); + choixFrame.add(boutonsPanel, BorderLayout.CENTER); + choixFrame.setVisible(true); + + automatiqueButton.addActionListener(new AutomatiqueActionListener(choixFrame)); + manuelButton.addActionListener(new ManuelActionListener(choixFrame)); + } +} diff --git a/FenetrePrincipale.class b/FenetrePrincipale.class new file mode 100644 index 0000000000000000000000000000000000000000..36ba0cc411e29f8835c8084424bbd4cb0aaac347 GIT binary patch literal 1143 zcmZuxTTc^F5dKbSyUViN3I%Gt6cj8-saH_0LKOtcB@{^t(d5vc!oqg9*=|ApivIxL z^r1~8@uhG6CyjF!65D7WX3m+Nnf<6pU+VLqc9A6eLwVmZ?uvJeB^LG|#1Z(TYh-sd%a36{Z!;D41mk&Kj2C z&NH;cNB0=~DLXG1I@5+FHY>$L;q3B5lOifF6pY-la2S;M{=vbj%x=%PJa@XmOE*bc z#;!Oyv24hSzGYzv*Ad%}VdabxH^syWKjS)XA<7Vv=TFJ^B!lDAJQ zGG$K3JQf)A3^&S#SaA%~6!O7qhMuO{rHbp?7DLBQ{ZeuX<-lp^rgw44@~YR+1qrxL!OZjjMc!t(t%M3^zq4{w0CijtW2#TKoQ{M6@1xH zOAY?bM6im$6@uCE8kA{&^fQL9pk_m@HE7d;2t8`cjz|18=vA~QB7sn66Dc+7aI_RIH6AK8@hW20`z1T(= a@6nGBL^DQJZD7B!puneiBnG{vLw^7+JP$|! literal 0 HcmV?d00001 diff --git a/FenetrePrincipale.java b/FenetrePrincipale.java new file mode 100644 index 0000000..3a3f703 --- /dev/null +++ b/FenetrePrincipale.java @@ -0,0 +1,25 @@ + +import javax.swing.*; +import java.awt.*; + + +public class FenetrePrincipale { + public void afficher(boolean modeAutomatique, int[][] grille) { + JFrame frame = new JFrame("Sudoku"); + frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + SaisieGrille saisieGrille = new SaisieGrille(grille); + + if (!modeAutomatique) { + JButton reinitialiserButton = new JButton("Réinitialiser"); + reinitialiserButton.addActionListener(new ReinitialiserActionListener(grille, saisieGrille)); + frame.add(reinitialiserButton, BorderLayout.SOUTH); + } + + frame.add(saisieGrille, BorderLayout.CENTER); + frame.pack(); + frame.setLocationRelativeTo(null); + frame.setVisible(true); + + System.out.println("La fenêtre Sudoku a été affichée."); + } +} diff --git a/GenerateurSudoku.class b/GenerateurSudoku.class index d9f681a11b2d34af195bf4992e0dc8c79dfd5756..2340c60c6c3734dc73988e9015c978abca95e5c0 100644 GIT binary patch delta 17 Zcmcb>dV!VW)W2Q(7#JALH*%a{0sunf2CV=9 delta 17 Zcmcb>dV!VW)W2Q(7#J8#HgcR`0sunQ2C4u6 diff --git a/GrillePainter.class b/GrillePainter.class new file mode 100644 index 0000000000000000000000000000000000000000..f3893929fe57b3e131714199bdcaf8bf6664c7da GIT binary patch literal 1296 zcmZuwO-~b16g{t<>Cj>LEF+4bBB;|+s8$6PRGzCFp(AcBsKgd*8k1ow@hC^V)CwA3p;az>JIlPDnT@!-G>2 zI)&jUfD8erInpJg8)tYp%fmU2X?_F|lF@@O550V&Peugid3ixXRKi6D-;kL#3pW_N zTJS!D5X+?vhK7WhHKx}eE*bWmzGM+npEmM&0__Rgv^dbMC06teJ)&cV!BQD{Nf=MJ4OktWd|D%ba(HUpy+2zR0(u$EPkU_43(r^a<)Zd&PXZtavp(Yb=|&EGc!FF~hRfxxqDQTi@i@ z$slQQdia2PSAHyK(5Oik$wRFpIhL0QBt+&XsnA=?W2-6rZ0JNY{a5(o z0sT^-QanOc2d#`&F|-TzjuM7eiarPQ!jGdkMmbU0GeRX=#n2acrou&dr^BBh%r}d> z@D(9>`vq0#DWZnH{>%>UIhB9y6~@9|CzmtsHYIYV3>HxvE~o$J5n)SUZ~p9rdk@Xo z#-_JlR7JP*HWowgp%hUUa!_{+AIZN()YH-VX?m(W70?*kgkd`=Rr#RJK_ zDxzsiBn>YdB~Q6k9>=O_$5#;|*&~xdtz?=;SroNMLP3G*M`*-jx`F4!eNFDaCI7#Y zso#nHgDn0@_&%DMfOfP|=PuOjqfLTG!g2N+^S>bOL1KGoq$*7nedt!&9T6RW0e>GT AbpQYW literal 0 HcmV?d00001 diff --git a/GrillePainter.java b/GrillePainter.java new file mode 100644 index 0000000..9742d80 --- /dev/null +++ b/GrillePainter.java @@ -0,0 +1,29 @@ +import java.awt.*; + +public class GrillePainter { + public static void dessinerGrille(Graphics g, SaisieGrille panel) { + Graphics2D g2d = (Graphics2D) g; + Stroke ancienStroke = g2d.getStroke(); + g2d.setStroke(new BasicStroke(4)); + + for (int i = 0; i <= panel.getTailleGrille() * panel.getTailleRegion(); i++) { + if (i % panel.getTailleRegion() == 0) { + g2d.drawLine(0, i * panel.getTailleCellule(), panel.getTailleGrille() * panel.getTailleRegion() * panel.getTailleCellule(), i * panel.getTailleCellule()); + g2d.drawLine(i * panel.getTailleCellule(), 0, i * panel.getTailleCellule(), panel.getTailleGrille() * panel.getTailleRegion() * panel.getTailleCellule()); + } + } + + g2d.setStroke(ancienStroke); + + for (int i = 0; i < panel.getTailleGrille() * panel.getTailleRegion(); i++) { + for (int j = 0; j < panel.getTailleGrille() * panel.getTailleRegion(); j++) { + g.setColor(Color.BLACK); + g.drawRect(j * panel.getTailleCellule(), i * panel.getTailleCellule(), panel.getTailleCellule(), panel.getTailleCellule()); + int valeur = panel.getGrille()[i][j]; + if (valeur != 0) { + g.drawString(String.valueOf(valeur), j * panel.getTailleCellule() + panel.getTailleCellule() / 2, i * panel.getTailleCellule() + panel.getTailleCellule() / 2); + } + } + } + } +} diff --git a/GrilleSudokuDessin.class b/GrilleSudokuDessin.class index 1ef653fd07a45a86553270219247c9b598f188cd..2554d2a317ce0c2139033d98bf00114bc7895111 100644 GIT binary patch delta 179 zcmWlTIc~yG6h+U+7SDeA6_raQGB|O7fEh9;&IAOr0q-XZK);EUhCR@wprOk)*akw_ z&DA+N&HdFME&dOG8(_>rX>c0ib0(Y%vEp%|rC(Mh5w3)`pRGU%=_mo+YOX_i^p%u> zGGtWISh!ghTh}y+xplco>vxuW9^AJX#gCRJo-HqA!mH(tcj3eG$wZi1W_(%ZJJ6*_L&qs{4ulYI zB+Ig8+48sk=<0C({R19ZDrpKnaf*hLp{#h^s`Hg7sTyjAyZB@aiceihav#xyPlG_+ z#FNsb6{)tNvsvvuR|+#yk#0DXAknk*8H8(TmWGxQW6Ol8;o0)StKrS^&WB-Une%D+ eVzK*|Ywsp2)y$Er6G=IdlE7&Pgq*t`BYy#B>>bnq diff --git a/Main$1.class b/Main$1.class deleted file mode 100644 index 4d464fe0844af70e129504997a3a3c35b245683e..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1113 zcmZuxTT|0O6#kY1X+w}w1QZ2gDcF`vK=BG*kefv+jCFi~rzKrWAWfKTTJWd%3zSD4 z#f}fY@aAuF9M7gY1L{NeY);O8=R4myo9{oregiOzX9*Y>($R@w9VV{nNMj^{3`XM^ z({UYH9XaH6T*Y`C6FMd_rNPoLqu~a_g*taL_O9<7tpvO(7%r~w@j5@UoZ@xNV>dNdw)uqv5WBd&=H7Fo$^!4-7oSBZjfnz;Rt+mTF~xzh+iWkG<35 z;PhCSye@20)@=Lqy(GmR8(6>-4T}bruxwxjs|@Kv^}v_Xp)$>~FzKB1Yvn+gE;lO? zFr9pApnx@!P*KjzFc<~T6Tza(r4*7Osj9GCPI7PT>rzhtF!LNP|!(+*!FgT z1XqA$s*&l-ZbzMIB9+2`^oXR4WtE_*f7{BSl^sb1keHiDLO_rm;VHIf>?t(`w?xa_7i9m4aDD~W1_Wz z#5*KdN^hV;!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s-Y~ z0e6Ngd)g(`KoY}{UESGvae+eXJ@uzcC4!iUj3?7_WZ-BuQHx~pF3oc^A$ZYEwGVZW z=TqMKgc4PhMaz)PCC7JnrMoW_1>0|_c6FOpt3azq@d<~^T@y?TOjWk#?SMb^p>I5#oA}2dPsjoX7dw<%Gn-_@5sG5 mL%zA1Ug^R7i#LNTWfWmh^#WBNCA?WeT)+gOPS9HllfMC*YQx0< literal 0 HcmV?d00001 diff --git a/ManuelActionListener.java b/ManuelActionListener.java new file mode 100644 index 0000000..2d21105 --- /dev/null +++ b/ManuelActionListener.java @@ -0,0 +1,23 @@ + +import javax.swing.*; +import java.awt.event.*; + + +public class ManuelActionListener implements ActionListener { + private JFrame choixFrame; + + public ManuelActionListener(JFrame choixFrame) { + this.choixFrame = choixFrame; + } + + @Override + public void actionPerformed(ActionEvent e) { + choixFrame.dispose(); + + int[][] grille = GenerateurSudoku.genererGrille(); + System.out.println("Grille Sudoku générée avec succès."); + + FenetrePrincipale fenetrePrincipale = new FenetrePrincipale(); + fenetrePrincipale.afficher(false, grille); + } +} diff --git a/OuvertureFichier.class b/OuvertureFichier.class index b55b9a2300db3770f0ab4c4d510c86bcc43ac5e3..932c978b4fdfdeb2756c87b9122b023addae69a3 100644 GIT binary patch delta 551 zcmYk3%WG3X6vlryx%W=)WK3^uMvYdj??-Ztt(t0m)JGDnk9466OF_6TrB-Sq5?>&6 zQwq8$7S~d6ldUMk;6is@=wDP9#uG$w^PS;4XMQvD&6<7}On(3MQY&gvs!w6>;=M3k$U>N11;S!e>R}5t;hAP&f??L=DF3!gbv&B32AJ?D7Q}Z*1 zt6clrnyVMb#w*XKXC5`?>I;UkPb{-6=^++xmdygo(vaC@wg@H5Yb+~5+Afsaq&oue6gw0NC5JoEkxhR2pQY$` i#2x&Jw}DqxWI8C^|N0pman%Nnd`0LAW2dka?D`F2>{S&2 delta 681 zcmY+C+e;K-7>A$Potbavb8IJds#VwQT<*y{Y&9J;OU=WsbSYwBQD8)dR74joh5vx; zrHBy35(EW-N|I90Qr-0T)J5AnYY<(``@Qe){e91OnpI~_&wT&=VH@b9sA=Y~;)vp? z;+V$dxF*VpFr3t!qDzw^9cGy@WHmXu!|rKCk7f_Oiaw1;zap2XdCT>2K@~s}<_G42^ zwo$2lTe2j+O;?#HWvciBZ>%sFn3)h5uh74%WCJr{78B-9;D|T*&)O8|OhVVKDzqk? zoeHsnq~IAbQXDj8iB7RZ GIP?cIrfXRM diff --git a/Reinitialiser.class b/Reinitialiser.class index 2b9d80728102d91b8a6ef4313fa53a852cb00f7b..24351e8b301c2f6b5f68582b10756b56676e0d56 100644 GIT binary patch delta 17 Zcmcb>dV!VW)W2Q(7#JALH*%a{0sunf2CV=9 delta 17 Zcmcb>dV!VW)W2Q(7#J8#HgcR`0sunQ2C4u6 diff --git a/ReinitialiserActionListener.class b/ReinitialiserActionListener.class new file mode 100644 index 0000000000000000000000000000000000000000..8378a286c732eae8d005614fa28f8b1d237310b5 GIT binary patch literal 552 zcmZvZT}uK%6o%h%&DCvn)zm)Bv^&4Zi=ZxyAfh6$4>E-CYSl?bbcNm3epjFg1^s}2 zRCH!DY9R*B%$)O{=e*2(e7?Q|I7C517?}uEtjn;WVpBs9TQX!-Y^%tr*kK6uZ802j z2BqD;WY8T`ID%g+ld(qg&%I9aBVh^mm?2dpy}w#&F$7P?J%SkxVe#w9sKf1hvm^0_ z*>%O(y5;uc*dFm7L%!G;m{YT6KDjkM<(6AJ@g!&RT$eDdIiA>Eel8@SaL46nVGf1E z?QdyAI4-xiy(d9BV#w>zu&P5xlp*TtkYz(h5^D@uU&YU2h delta 17 Zcmcc4cAbsm)W2Q(7#J8#Hgfng0{}we20{P; diff --git a/SaisieGrille$1.class b/SaisieGrille$1.class deleted file mode 100644 index 73d31e9a1f13ec51ec2237c97a9451506404d074..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2040 zcma)7-E$LF6#v~e>84?!X`y^bt1A{s($YXh)D}<(Ed*PN1`AlfZj(#8b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v8cr~o^M@33rFXd^@5xFBnkatXOMm{RDK@TdO$Qu*`Cgi7Gg1j$|(h#CBr% zH%!&mu-%@TKr8dsJ>yMjYc2|ypLLcGh9Q0bqQ!v_D(6BV57i@`xhIfF=IZ4&88B%? zq24y%9!9f?sso4kdFkRK*3pS~aS#IUQEH*S6YswzA8wM5(1x4t+j7}`&Ntw5J_B-% zu~JBr_EGu=K?KOlsZEGf%Tu%{qNUPL5lE%C(pqNg4+N_V7d)+qKMjy6`>&W9Vv33T8B`2=MX`*0ikvA`~rkU>8^I}vz|!_aiJ>Ie$p zC3NuuoiA9KzyLn1SK3X^TLcyC?|BeV=|jHq6w~t|^US7*OVsMTd#=##Nk2zys;`Q+ z>Aq)ZpKp(EqN9q0HW)|*V&TU)nFxf+k8re4qnuf0(LS$YZ=Zi?sHs^Gus?tG9ozBW zz%6Ysme(-bqyzH=-S%T#fIn3*k;2=)(#5}|L=l}?0yMyGEVJ8-vV zdf;vq@2m%z;fbH;@lKOx*+kXqAkOjsX_zfO&-EJNf{d~YSxRHLLisv!{HmG!7EPgy zX{=!eU-KX98{R&`ES^yR3-5o!oZoz|=_?%65z}!(9B0c_^Isw?{zHzEnt_IsOx=Q0 S7$gs{#Rj^0iuflUfd2tN7N#Ts diff --git a/SaisieGrille.java b/SaisieGrille.java index aa1947b..85f5912 100644 --- a/SaisieGrille.java +++ b/SaisieGrille.java @@ -7,13 +7,12 @@ public class SaisieGrille extends JPanel { private static final int TAILLE_REGION = 3; private static final int TAILLE_CELLULE = 50; private int[][] grille; - private int[][] grilleInitiale; // Pour stocker la grille initiale + private int[][] grilleInitiale; private int ligneSelectionnee = -1; private int colonneSelectionnee = -1; public SaisieGrille(int[][] grille) { this.grille = grille; - // Copie de la grille initiale this.grilleInitiale = new int[grille.length][grille[0].length]; for (int i = 0; i < grille.length; i++) { for (int j = 0; j < grille[i].length; j++) { @@ -21,67 +20,79 @@ public class SaisieGrille extends JPanel { } } setPreferredSize(new Dimension(TAILLE_GRILLE * TAILLE_REGION * TAILLE_CELLULE, TAILLE_GRILLE * TAILLE_REGION * TAILLE_CELLULE)); - setFocusable(true); // Permet au JPanel de recevoir les événements de souris + setFocusable(true); - addMouseListener(new MouseAdapter() { - @Override - public void mouseClicked(MouseEvent e) { - int x = e.getX() / TAILLE_CELLULE; - int y = e.getY() / TAILLE_CELLULE; - if (x >= 0 && x < TAILLE_GRILLE * TAILLE_REGION && y >= 0 && y < TAILLE_GRILLE * TAILLE_REGION) { - ligneSelectionnee = y; - colonneSelectionnee = x; - System.out.println("Case sélectionnée : (" + ligneSelectionnee + ", " + colonneSelectionnee + ")"); - if (grilleInitiale[ligneSelectionnee][colonneSelectionnee] == 0) { // Ne permet la modification que pour les cellules vides - String valeurStr = JOptionPane.showInputDialog(null, "Entrez la valeur pour la cellule sélectionnée :"); - try { - int valeur = Integer.parseInt(valeurStr); - grille[ligneSelectionnee][colonneSelectionnee] = valeur; - repaint(); - } catch (NumberFormatException ex) { - JOptionPane.showMessageDialog(null, "Saisie invalide. Veuillez entrer un nombre."); - } - } else { - JOptionPane.showMessageDialog(null, "Vous ne pouvez pas modifier la valeur par défaut."); - } - } - } - }); + addMouseListener(new CaseMouseListener(this)); } public int[][] getGrilleInitiale() { return grilleInitiale; } - @Override - protected void paintComponent(Graphics g) { - super.paintComponent(g); + public int getTailleGrille() { + return TAILLE_GRILLE; + } - // Dessiner les contours de la grille (en gras) - Graphics2D g2d = (Graphics2D) g; - Stroke ancienStroke = g2d.getStroke(); // Sauvegarder le style de ligne précédent - g2d.setStroke(new BasicStroke(4)); // Épaisseur de ligne de 4 pixels + public int getTailleRegion() { + return TAILLE_REGION; + } - for (int i = 0; i <= TAILLE_GRILLE * TAILLE_REGION; i++) { - if (i % TAILLE_REGION == 0) { - g2d.drawLine(0, i * TAILLE_CELLULE, TAILLE_GRILLE * TAILLE_REGION * TAILLE_CELLULE, i * TAILLE_CELLULE); - g2d.drawLine(i * TAILLE_CELLULE, 0, i * TAILLE_CELLULE, TAILLE_GRILLE * TAILLE_REGION * TAILLE_CELLULE); + public int getTailleCellule() { + return TAILLE_CELLULE; + } + + public void setLigneSelectionnee(int ligneSelectionnee) { + this.ligneSelectionnee = ligneSelectionnee; + } + + public void setColonneSelectionnee(int colonneSelectionnee) { + this.colonneSelectionnee = colonneSelectionnee; + } + + public int getLigneSelectionnee() { + return ligneSelectionnee; + } + + public int getColonneSelectionnee() { + return colonneSelectionnee; + } + + public int[][] getGrille() { + return grille; + } + + public boolean validerChiffre(int ligne, int colonne, int chiffre) { + // Vérifier la ligne + for (int j = 0; j < grille.length; j++) { + if (grille[ligne][j] == chiffre && j != colonne) { + return false; } } - // Rétablir le style de ligne précédent - g2d.setStroke(ancienStroke); + // Vérifier la colonne + for (int i = 0; i < grille.length; i++) { + if (grille[i][colonne] == chiffre && i != ligne) { + return false; + } + } - // Dessiner les cellules de la grille - for (int i = 0; i < TAILLE_GRILLE * TAILLE_REGION; i++) { - for (int j = 0; j < TAILLE_GRILLE * TAILLE_REGION; j++) { - g.setColor(Color.BLACK); - g.drawRect(j * TAILLE_CELLULE, i * TAILLE_CELLULE, TAILLE_CELLULE, TAILLE_CELLULE); - int valeur = grille[i][j]; - if (valeur != 0) { - g.drawString(String.valueOf(valeur), j * TAILLE_CELLULE + TAILLE_CELLULE / 2, i * TAILLE_CELLULE + TAILLE_CELLULE / 2); + // Vérifier la région + int regionX = colonne / TAILLE_REGION; + int regionY = ligne / TAILLE_REGION; + for (int i = regionY * TAILLE_REGION; i < (regionY + 1) * TAILLE_REGION; i++) { + for (int j = regionX * TAILLE_REGION; j < (regionX + 1) * TAILLE_REGION; j++) { + if (grille[i][j] == chiffre && (i != ligne || j != colonne)) { + return false; } } } + + return true; + } + + @Override + protected void paintComponent(Graphics g) { + super.paintComponent(g); + GrillePainter.dessinerGrille(g, this); } }