From 38b8e6d31c4ccdf15ff0eeda62e01daa6112ec72 Mon Sep 17 00:00:00 2001 From: dick Date: Wed, 3 Apr 2024 10:46:17 +0200 Subject: [PATCH] Auto --- Main.class | Bin 0 -> 704 bytes Main.java | 13 ++++++++++--- SudokuDraw.class | Bin 0 -> 1135 bytes SudokuDraw.java | 43 ++++++++++++++++++++++++++++++++++++++++++ SudokuGenerator.class | Bin 0 -> 717 bytes SudokuGenerator.java | 18 ++++++++++++++++-- SudokuPanel.class | Bin 0 -> 1130 bytes 7 files changed, 69 insertions(+), 5 deletions(-) create mode 100644 Main.class create mode 100644 SudokuDraw.class create mode 100644 SudokuDraw.java create mode 100644 SudokuGenerator.class create mode 100644 SudokuPanel.class diff --git a/Main.class b/Main.class new file mode 100644 index 0000000000000000000000000000000000000000..585252d92a180adfeca4a5cd2b5e9fcb78ae09c6 GIT binary patch literal 704 zcmZvaQBTuQ6vzK}?b@weWugKqh#<~(D-_hk2aGQx5X^wYkr~+2-F96rbnVi0%&+B3 zXC(0h_@RvFZYIQpKAdyz>HqxBIqm)Z=jSf~@A1yTeJnXx#uFP)3wY+hz=}4jHl91M zv8E3%v{~0?Lz|a2Hf_9Ous*0rr5_m#*K0DEwYV!8=IbhwC!>B_CTF4@QpW5H6)`Nj zt@@?77C|VYUeHJr74`OXq0@**Nk<+iEiN9Dcw6f@=25ay=6DU4VL|7<1;a6w1)mNQ z(I>Ul7Tk(PQK6;w5Cn%YmqSf_oCEo^fHC~@pym*WlI(oDJyL+N&))Apt8q%{Am z{!m6T5ow$-@ZKzzhl%Pk@7Afy6isYH@!MM>0zHyczxfBq0W(b4AUmNj>gNxu0c7{#u^J3`=*j^jD^e zrW&f*FL5utCf0F}E`WY=pv6%l`+!cXqm;P@=VoNs2}x7acPsTW~vnx;VTB39sF U19K>Yqe@fm&>LEsbU7^k1>jPWF#rGn literal 0 HcmV?d00001 diff --git a/Main.java b/Main.java index 1211a49..14399b0 100644 --- a/Main.java +++ b/Main.java @@ -1,8 +1,15 @@ -import javax.swing.JFrame; -import javax.swing.SwingUtilities; +import javax.swing.*; public class Main { public static void main(String[] args) { - + int[][] grid = SudokuGenerator.generateGrid(); + + JFrame frame = new JFrame("Sudoku"); + frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + SudokuDraw sudokuDraw = new SudokuDraw(grid); + frame.add(sudokuDraw); + frame.pack(); + frame.setLocationRelativeTo(null); // Centrer la fenêtre sur l'écran + frame.setVisible(true); } } diff --git a/SudokuDraw.class b/SudokuDraw.class new file mode 100644 index 0000000000000000000000000000000000000000..2872e91414fd7be27b7746ff5397e503fa076b81 GIT binary patch literal 1135 zcmZ8fOHUJF6g^*O%Ftne@+e4YRi5?%6sv;DODIT+6$mvX$N~pCz(|>?(!(L}m1#mq&dPVhoR3=j6i3beci)A>OA%?nh?%8@6Dydni zvZ1U=v4l@mxvpok3)&hjSfT+-BRWc1l{}y#`hhO>JI)g8i3>TZ15vaYKp&g&m z&m5IgxHj78*Q=&KLxdkSs0BG8s!ZrYYY`)Z_J`Dt5W+SU+RoguSJ^nHbHVjb;xh7P<$CtjfouhESUgg?^vPlzB$ eN`81wQNwzIzu`VbB|C-8`YEP|mUh|cd*vUXrt3xk literal 0 HcmV?d00001 diff --git a/SudokuDraw.java b/SudokuDraw.java new file mode 100644 index 0000000..8e391af --- /dev/null +++ b/SudokuDraw.java @@ -0,0 +1,43 @@ +import javax.swing.*; +import java.awt.*; + +public class SudokuDraw extends JPanel { + private static final int GRID_SIZE = 3; + private static final int REGION_SIZE = 3; + private static final int CELL_SIZE = 50; + + private int[][] grid; + + public SudokuDraw(int[][] grid) { + this.grid = grid; + setPreferredSize(new Dimension(GRID_SIZE * REGION_SIZE * CELL_SIZE, GRID_SIZE * REGION_SIZE * CELL_SIZE)); + } + + @Override + protected void paintComponent(Graphics g) { + super.paintComponent(g); + + // Dessiner des lignes plus épaisses pour la grille 3x3 + g.setColor(Color.BLACK); + for (int i = 0; i <= GRID_SIZE * REGION_SIZE; i++) { + if (i % REGION_SIZE == 0) { + g.fillRect(0, i * CELL_SIZE - 2, GRID_SIZE * REGION_SIZE * CELL_SIZE, 4); + g.fillRect(i * CELL_SIZE - 2, 0, 4, GRID_SIZE * REGION_SIZE * CELL_SIZE); + } else { + g.fillRect(0, i * CELL_SIZE - 1, GRID_SIZE * REGION_SIZE * CELL_SIZE, 2); + g.fillRect(i * CELL_SIZE - 1, 0, 2, GRID_SIZE * REGION_SIZE * CELL_SIZE); + } + } + + // Dessiner les valeurs de la grille + g.setColor(Color.BLACK); + for (int i = 0; i < grid.length; i++) { + for (int j = 0; j < grid[i].length; j++) { + int value = grid[i][j]; + if (value != 0) { + g.drawString(String.valueOf(value), j * CELL_SIZE + CELL_SIZE / 2, i * CELL_SIZE + CELL_SIZE / 2); + } + } + } + } +} diff --git a/SudokuGenerator.class b/SudokuGenerator.class new file mode 100644 index 0000000000000000000000000000000000000000..2331083d2b5444c900c312732715f99ee5a550be GIT binary patch literal 717 zcmZvazfQw25QoqCV<({yBe62DwH;t&K`cmA2tn+S5dz2WdeP!JbYIX34RGkbA0DekI4Ll))XEPY5j zX1aM@V1X$pm+N(B%Ux3waSm>TAy(Tc%7ab1rzu% z?yYcliNm!9)_4x`AQrP~o+-o^-NM+S&M&G*eSZJ| literal 0 HcmV?d00001 diff --git a/SudokuGenerator.java b/SudokuGenerator.java index 77f4740..de7719d 100644 --- a/SudokuGenerator.java +++ b/SudokuGenerator.java @@ -1,3 +1,17 @@ public class SudokuGenerator { - -} \ No newline at end of file + public static int[][] generateGrid() { + int[][] grid = { + {0, 0, 0, 9, 0, 5, 0, 0, 4}, + {5, 0, 3, 0, 0, 4, 0, 8, 7}, + {0, 0, 0, 7, 0, 0, 6, 0, 3}, + {9, 0, 0, 0, 3, 4, 0, 8, 0}, + {0, 4, 0, 0, 1, 0, 0, 7, 0}, + {0, 2, 0, 5, 7, 0, 0, 0, 6}, + {4, 0, 9, 0, 0, 2, 0, 0, 0}, + {6, 0, 7, 9, 0, 3, 0, 2, 1}, + {2, 0, 0, 6, 5, 0, 0, 0, 0} + }; + + return grid; + } +} diff --git a/SudokuPanel.class b/SudokuPanel.class new file mode 100644 index 0000000000000000000000000000000000000000..4d692d7462bab0f2ee101647aa8d488f77bd0bcc GIT binary patch literal 1130 zcmZ8gO-~b16g{sqWjezE1q1|I1qCTBP`(6_FR>yi79`Y=APXJZDU6hvI-P=X;fjSD ze}FF4gv6B)1)~WIm&RXYheh^%fR9cRWZxVJDTaNXxV}; zPz8aZa(Q+xet)q~&(cnHPBTm=W^LyzQ#T!k#!%vkwxdP0T_-wcYq?D$l^^F4RY^xnZ7pcI z(n%$073`FL*Wfbp0?G98gDRTPuc85s40Y#9cZ_Y_%o~5#E(AV`Q_-dWvQ%QG=xxU8Sr>9+HktRw%i{zxMqMLqjOuT`XQkpz=!E)^^Y6 zXO7A#TpMk4>#FEdh-g7IYCuj1c~DEZ?mt{#hA$9@zM9LWf#D*ZY$h}fFJ*w%@G)38 z@)@4+Hwde>>^nWj@E)P!fYOZQK?OuwTWD>Ci~vPJHx3lVSTBiriE$8)97Bp6!gmB& zm<;&kcUTNm8NFZ8_f_)=mgZLUPkp}S#DuYzk-~5=@qt_ACJ%OZtx`N-hMUQK7 zo=gJmWTOKrI&lHlXupg8<`Bja#ylcerTs_fM+O6UO4s`ZhVT-@ctyASJ>d_u{}E#} f96l`h6xFOJ_zT`s_}D2F)=x1#G_*@@-OGOg%Yo`> literal 0 HcmV?d00001