From 2b12e4c7eb6c788a32ae474cea16d31c3e888bb5 Mon Sep 17 00:00:00 2001 From: JunkJumper Date: Wed, 2 Sep 2020 15:31:15 +0200 Subject: [PATCH] exo 3 ok --- .classpath | 12 +++++++++++- src/TP1/Eponge.java | 5 ----- src/TP1/FenetreG.java | 24 ++++++++++++++++++++++-- 3 files changed, 33 insertions(+), 8 deletions(-) delete mode 100644 src/TP1/Eponge.java diff --git a/.classpath b/.classpath index fb50116..d3688f0 100644 --- a/.classpath +++ b/.classpath @@ -1,6 +1,16 @@ - + + + + + + + + + + + diff --git a/src/TP1/Eponge.java b/src/TP1/Eponge.java deleted file mode 100644 index 1a2e1db..0000000 --- a/src/TP1/Eponge.java +++ /dev/null @@ -1,5 +0,0 @@ -package TP1; - -public class Eponge { - -} diff --git a/src/TP1/FenetreG.java b/src/TP1/FenetreG.java index 9c679af..dd27415 100644 --- a/src/TP1/FenetreG.java +++ b/src/TP1/FenetreG.java @@ -3,12 +3,33 @@ package TP1; import java.awt.Graphics; import java.util.Random; -import javax.swing.JFrame; +import javax.swing.JFrame; public class FenetreG extends JFrame { static Random generator = new Random() ; + public void paint(Graphics g) { + menger(g, 400, 50, (int) Math.pow(3, 6)); + } + + + public void menger(Graphics g, int x, int y, int taille) { + if (taille <= 1) { + g.drawRect(x, y, 1, 1); + } else { + menger(g, x, y, taille/3); + menger(g, x, y + taille/3, taille/3); + menger(g, x, y + 2 * taille/3, taille/3); + + menger(g, x + taille/3, y, taille/3); + menger(g, x + taille/3, y + 2 * taille/3, taille/3); + + menger(g, x + 2 * taille/3, y, taille/3); + menger(g, x + 2 * taille/3, y + taille/3, taille/3); + menger(g, x + 2 * taille/3, y + 2 * taille/3, taille/3); + + } } public static void main(String[] args) { @@ -16,7 +37,6 @@ public class FenetreG extends JFrame { fenetre.setDefaultCloseOperation(EXIT_ON_CLOSE) ; fenetre.setExtendedState(MAXIMIZED_BOTH) ; fenetre.setVisible(true) ; - fenetre.triGraphique(); fenetre.repaint(); } } \ No newline at end of file