From b1a83ffc243c975daeb6dbb6fc2fab3471d70a65 Mon Sep 17 00:00:00 2001 From: Wamster Date: Tue, 19 Dec 2023 19:50:02 +0100 Subject: [PATCH] fin du cotrole blanc dev32 --- .../Q1_Annulation/Coche.java | 15 ----- .../Q1_Annulation/EvenementIngredient.class | Bin 0 -> 915 bytes .../Q1_Annulation/EvenementIngredient.java | 9 +-- .../Q1_Annulation/EvenementRetour.class | Bin 0 -> 979 bytes .../Q1_Annulation/EvenementRetour.java | 24 +++----- .../Q1_Annulation/Fenetre.class | Bin 0 -> 1546 bytes .../Q1_Annulation/Fenetre.java | 14 +++-- .../Q1_Annulation/Ingredient.class | Bin 0 -> 843 bytes .../Q1_Annulation/Ingredient.java | 2 +- .../Q1_Annulation/Main.class | Bin 0 -> 322 bytes .../Q1_Annulation/{Q4Main.java => Main.java} | 2 +- .../Q1_Annulation/PileIngredient.java | 23 -------- .../Q2_Perfection/Arbre.java | 55 ++++++++++++++++++ .../Q2_Perfection/Main.java | 24 ++++++++ .../Q2_Perfection/Noeud.java | 31 ++++++++++ 15 files changed, 133 insertions(+), 66 deletions(-) delete mode 100644 DEV/DEV3.2/Controle_Machine_Blanc/Q1_Annulation/Coche.java create mode 100644 DEV/DEV3.2/Controle_Machine_Blanc/Q1_Annulation/EvenementIngredient.class create mode 100644 DEV/DEV3.2/Controle_Machine_Blanc/Q1_Annulation/EvenementRetour.class create mode 100644 DEV/DEV3.2/Controle_Machine_Blanc/Q1_Annulation/Fenetre.class create mode 100644 DEV/DEV3.2/Controle_Machine_Blanc/Q1_Annulation/Ingredient.class create mode 100644 DEV/DEV3.2/Controle_Machine_Blanc/Q1_Annulation/Main.class rename DEV/DEV3.2/Controle_Machine_Blanc/Q1_Annulation/{Q4Main.java => Main.java} (89%) delete mode 100644 DEV/DEV3.2/Controle_Machine_Blanc/Q1_Annulation/PileIngredient.java create mode 100644 DEV/DEV3.2/Controle_Machine_Blanc/Q2_Perfection/Arbre.java create mode 100644 DEV/DEV3.2/Controle_Machine_Blanc/Q2_Perfection/Main.java create mode 100644 DEV/DEV3.2/Controle_Machine_Blanc/Q2_Perfection/Noeud.java diff --git a/DEV/DEV3.2/Controle_Machine_Blanc/Q1_Annulation/Coche.java b/DEV/DEV3.2/Controle_Machine_Blanc/Q1_Annulation/Coche.java deleted file mode 100644 index e12b59e..0000000 --- a/DEV/DEV3.2/Controle_Machine_Blanc/Q1_Annulation/Coche.java +++ /dev/null @@ -1,15 +0,0 @@ -import javax.swing.JCheckBox; - -public class Coche extends JCheckBox{ - - private Ingredient valeur; - - public Coche(Ingredient valeur){ - super(valeur.name()); - this.valeur = valeur; - } - - public Ingredient getValeur(){ - return this.valeur; - } -} \ No newline at end of file diff --git a/DEV/DEV3.2/Controle_Machine_Blanc/Q1_Annulation/EvenementIngredient.class b/DEV/DEV3.2/Controle_Machine_Blanc/Q1_Annulation/EvenementIngredient.class new file mode 100644 index 0000000000000000000000000000000000000000..83dd040ef2c55963180d92190598eeb12e307148 GIT binary patch literal 915 zcmZ`%U2hUW6g>mj71$OEtzxli{e%U(8hxXw30RXFs)?9B__n|VroyhmY|Gy=u{HW& zeD+5f&uoddlxDMc?%aFl%(?f>?>|3&0(g$6DI~F$#8niHxtYQ`ZdtgU#vN>=a2NM1 z+_&(+!b5>fUyXGzQlCTF=m%;du-rWG4m~&2YT&+|oP36ls;jk@7@4fbbk@^LY%PC%po>f{7TiVl{i|6-bS73dL>m6xV9!g)kyR6wU zUd<3nwb*1wzEXxn!Nlc|xm~|El3hh_(@fUJG9KAT!?uw@)+tpR#51u9lfkobiwd(KzHs^75?1HE|S1lBBQj%@S1U historiqueChoix; private JButton boutonRetour; - public EvenementIngredient(PileIngredient historiqueChoix, JButton boutonRetour){ + public EvenementIngredient(Deque historiqueChoix, JButton boutonRetour){ this.historiqueChoix = historiqueChoix; this.boutonRetour = boutonRetour; } @Override public void itemStateChanged(ItemEvent e){ - Coche coche = (Coche) e.getSource(); - this.historiqueChoix.push(coche.getValeur()); + JCheckBox coche = (JCheckBox) e.getSource(); + this.historiqueChoix.push(coche); this.boutonRetour.setEnabled(true); } } diff --git a/DEV/DEV3.2/Controle_Machine_Blanc/Q1_Annulation/EvenementRetour.class b/DEV/DEV3.2/Controle_Machine_Blanc/Q1_Annulation/EvenementRetour.class new file mode 100644 index 0000000000000000000000000000000000000000..409973f1302f7e1944c500e28bf55d230f0c66aa GIT binary patch literal 979 zcmZ`&%Tg0T6g@o|X)+n!5fuf*X9$nMHyVl(5EmApWh|{?H-r`jl9@Q^0Dg-80Bfr> zmM$#Tew286Vu1u*OyBNv`rgxhZqLtO-+utOi-H3em($2#B!ersDsj!hb=;7+>A*(L z45Nn0J7~k0#JI$S#H4_;8Ps$X2k+`ipl4~z-|@Y=4$9sWMW`T(HWP$_o)yUETGI-nuLbOdXq`2?mV!{N)GKQ$e&w%~ ziAQVvqzZbeOe?1x|6n)eR}+SZA+E3z+eKkUT}%cG`vU6|S2UYr zCsG_UeAzD2tkta0Pxc(nb2Rz;%(fZl@}FUSLrUNP_VQQ*XAaP|GCtmb{0M39!%j8O zezfULbCwqPfc6Pej*+zz*&#^Idnnk;bszt-EIiH%=*MFUUm!b$)FE$aOAJU{l(-}@ T2*G$r@+4{z6(li~C=CAw#Dv+o literal 0 HcmV?d00001 diff --git a/DEV/DEV3.2/Controle_Machine_Blanc/Q1_Annulation/EvenementRetour.java b/DEV/DEV3.2/Controle_Machine_Blanc/Q1_Annulation/EvenementRetour.java index 6470b98..a1f548f 100644 --- a/DEV/DEV3.2/Controle_Machine_Blanc/Q1_Annulation/EvenementRetour.java +++ b/DEV/DEV3.2/Controle_Machine_Blanc/Q1_Annulation/EvenementRetour.java @@ -1,33 +1,25 @@ import javax.swing.*; import java.awt.*; import java.awt.event.*; +import java.util.Deque; public class EvenementRetour implements ActionListener{ - private PileIngredient historique; - private Coche[] listeCoche; - private EvenementIngredient evenementIngredient; + private Deque historique; - public EvenementRetour(PileIngredient historique, Coche[] listeCoche, EvenementIngredient evenementIngredient){ + public EvenementRetour(Deque historique){ this.historique = historique; - this.listeCoche = listeCoche; - this.evenementIngredient = evenementIngredient; } @Override public void actionPerformed(ActionEvent e){ - Ingredient dernierChoisis = this.historique.pop(); + JCheckBox dernierChoisis = this.historique.pop(); JButton boutonRetour = (JButton) e.getSource(); - for (Coche coche : this.listeCoche){ - if (coche.getValeur() == dernierChoisis){ - coche.removeItemListener(evenementIngredient); - coche.setSelected(!coche.isSelected()); - coche.addItemListener(evenementIngredient); - if (historique.isEmpty()){ - boutonRetour.setEnabled(false); - } - } + dernierChoisis.setSelected(!dernierChoisis.isSelected()); // cette ligne declenche l'evenementIngredient + this.historique.pop(); // il faut donc retirer le dernier ingredient ajouter malencontreusement + if (historique.isEmpty()){ + boutonRetour.setEnabled(false); } } } diff --git a/DEV/DEV3.2/Controle_Machine_Blanc/Q1_Annulation/Fenetre.class b/DEV/DEV3.2/Controle_Machine_Blanc/Q1_Annulation/Fenetre.class new file mode 100644 index 0000000000000000000000000000000000000000..2773114bf0be00dee63830b8fc1646afa2d3cc80 GIT binary patch literal 1546 zcmZ`(QCAy97`>Y;8CaIm1kyrdwWU?VrjQmZT0krWsMG*0p{*%ZyCef$o9yDUp~VNE z`lSED7oR=HCOziZAK;Te#%JrDO>9Cvo}A3?eDlry?!Dj6{PFj1F9BS|o`D!H_u`6y zw=t!L57cl~;6wGC7Wl|OFE00S^0A6s6PW46tN{~q0-qQd#Jqt|aa~|RV9~%3aw>00 z1(yvZFsFtU6}utunSnD{Rl9Gh;d6n!2IG-)5O}`xZB1&3=fANJ?QAV@D%mB;(5!~O zg0tt^LCxp7_2&9q7f(e(IT4SLQi6Jjv$ zxN^N#-I4y5y;EUiz%G|p-92BH9q9&~7XrKVc+K7q*GZD9sa9Z3V4Z{uUd=Db6-Vtg zSEMTgUrs9CCNAJ23E!^CgTV3JD<(E@%fxMLnkZmXLqes!X1n6sRcT@icQg!lgfIBM zeH5xU@eaIrMm+6OniZ&hU77r zfBkC1XYD6J_J;42^Y)Qf3)EIZ-^aFz2l&#&SNPh*L)dijb)`)i&<~ZmW1@tz35i_| zqHPTA+|GB{uq`9o|I;%Ky$3Sbasp*+GTmx*#b#d%fzS5NsxAtq6rAsv(UV?XRgr#1 z@?ObSjuV};CAn+YDnYK|9mtJ+>9?2kbeKQhM(+B^juUEm8&)$q%<1)^U14V_K0W@1 zrar|X^h`sljjz0H#nx=s-jjZasJrYr+npZ&uRbEHPce|yJkJC>>1#OGg(lhEAltnj zLPoiXN24n-=T-MTm&vp3DvC=dsLHphcX^=)Ri}c0diuVK#fiR9Qs#C@jdj&( zkvg71S~$-$ALBKnA)>xwKF@O&!5IGl+%Fq-50BxZV8cc_@u^@n-`!*wL1 z)3IbMssDuRXiqZMM4~v6j7`;Xs)5r56`CUP5i5MFWAxs$nD+ClKbtrcR%jqKBQg~A zR%TSxan{PH93>_KC1#PNfh2{T!fF0e7@?3+uB9-Iv$#%I3yeIVqr03}=;RTleNQi+ jG3y5kO%ox7$SYif5EvJ*1Tq4bG=T}KpP~ historique; public Fenetre(){ super(); @@ -11,7 +13,7 @@ public class Fenetre extends JFrame{ this.setSize(500, 300); this.setLocation(0, 0); this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); - this.historique = new PileIngredient(); + this.historique = new ArrayDeque<>(); this.addIngredient(); } @@ -20,17 +22,17 @@ public class Fenetre extends JFrame{ EvenementIngredient evenementIngredient = new EvenementIngredient(this.historique, retour); Ingredient[] listeIngredient = Ingredient.values(); int nbIngredient = listeIngredient.length; - Coche[] listeCoche = new Coche[nbIngredient]; + JCheckBox[] listeCoche = new JCheckBox[nbIngredient]; int i; - this.setLayout(new GridLayout(1,nbIngredient+1)); + this.setLayout(new GridLayout(nbIngredient+1,1)); for (i=0; i9#lvO;}QNRutmWHBENsA+@ z8Wy>(X)w9oRq=u$>)IXrO^dNISZ1ITJ9ESgHt)?2ZqU5ZZu6{t{>h3s+ zhyL4uGb_$FvB!xSc)<5sHt-UAgq^1iETeAV304dgQ8KW|g^3bFVLlS?$dDO^^)k(h^GkFY;NoGZkR!Y-VZt#+b>ZVfrhRhX|`*?{j0+Oh|2AMuU zt?jN{BKzfD@uw7#unG-pB(F*NM3Nu-2b8|4%9qeCkQ0us2xmb!Mn*XK>`%hUGkW{J kGQ)z~&&-f_FTm#QOi@xop4e2#-l0|!uA8spnIN(87fS!16951J literal 0 HcmV?d00001 diff --git a/DEV/DEV3.2/Controle_Machine_Blanc/Q1_Annulation/Ingredient.java b/DEV/DEV3.2/Controle_Machine_Blanc/Q1_Annulation/Ingredient.java index 4aa98ef..21372f5 100644 --- a/DEV/DEV3.2/Controle_Machine_Blanc/Q1_Annulation/Ingredient.java +++ b/DEV/DEV3.2/Controle_Machine_Blanc/Q1_Annulation/Ingredient.java @@ -1,5 +1,5 @@ enum Ingredient{ SALADE, TOMATES, - OIGNONS + OIGNONS, } \ No newline at end of file diff --git a/DEV/DEV3.2/Controle_Machine_Blanc/Q1_Annulation/Main.class b/DEV/DEV3.2/Controle_Machine_Blanc/Q1_Annulation/Main.class new file mode 100644 index 0000000000000000000000000000000000000000..bd95a945aed92171a5f7acb2a3312834d329fbd7 GIT binary patch literal 322 zcmYLDJx{|h6g($sz6eSA>c+s9g48bEKrBd|0t`iwfXOLV<*Ie1)a8G%PzfY{06z+G zR)^Zs-Sc~Q_x$_!^#fppUWyP!gl-BCg@dCA#}Q5h!W(V0y%q4wek~B(t=^PCQE8(d zHp@n}PqJCC6D*}R0=@FJn#*@NTu3t;PHd~q?AjUA$!gP1)mS@ma!>KV=`uu!1){Ms z%C;)QDb5(?<^tV)(ql7MQ_GmOvbA38-Olo*U*iHD{@xuAOhQad_&O&Ga_4dj@xg*_ qVz_Hka)6ArlMZP0$oV(C=Pmr|D)>aO_vG+7jd>FsGDQ&Gy8Is>BQ>)C literal 0 HcmV?d00001 diff --git a/DEV/DEV3.2/Controle_Machine_Blanc/Q1_Annulation/Q4Main.java b/DEV/DEV3.2/Controle_Machine_Blanc/Q1_Annulation/Main.java similarity index 89% rename from DEV/DEV3.2/Controle_Machine_Blanc/Q1_Annulation/Q4Main.java rename to DEV/DEV3.2/Controle_Machine_Blanc/Q1_Annulation/Main.java index 9e4e7bf..08ec9a9 100644 --- a/DEV/DEV3.2/Controle_Machine_Blanc/Q1_Annulation/Q4Main.java +++ b/DEV/DEV3.2/Controle_Machine_Blanc/Q1_Annulation/Main.java @@ -2,7 +2,7 @@ import javax.swing.*; import java.awt.*; import java.awt.event.*; -public class Q4Main{ +public class Main{ public static void main(String[] args) { Fenetre fenetre = new Fenetre(); diff --git a/DEV/DEV3.2/Controle_Machine_Blanc/Q1_Annulation/PileIngredient.java b/DEV/DEV3.2/Controle_Machine_Blanc/Q1_Annulation/PileIngredient.java deleted file mode 100644 index bd0b9a9..0000000 --- a/DEV/DEV3.2/Controle_Machine_Blanc/Q1_Annulation/PileIngredient.java +++ /dev/null @@ -1,23 +0,0 @@ -import java.util.*; - -public class PileIngredient{ - - private Deque pile; - - public PileIngredient(){ - this.pile = new ArrayDeque<>(); - } - - public void push(Ingredient valeur){ - this.pile.push(valeur); - } - - public Ingredient pop(){ - return this.pile.pop(); - - } - - public boolean isEmpty(){ - return this.pile.isEmpty(); - } -} \ No newline at end of file diff --git a/DEV/DEV3.2/Controle_Machine_Blanc/Q2_Perfection/Arbre.java b/DEV/DEV3.2/Controle_Machine_Blanc/Q2_Perfection/Arbre.java new file mode 100644 index 0000000..b52ebd8 --- /dev/null +++ b/DEV/DEV3.2/Controle_Machine_Blanc/Q2_Perfection/Arbre.java @@ -0,0 +1,55 @@ +import java.util.*; + +public class Arbre{ + + private Noeud racine = null; + private int nbNoeud = 0; + + public Arbre(int[] tableau){ + for (int valeur : tableau){ + this.add(valeur); + } + } + + public void add(int valeur){ + this.nbNoeud ++; + if (racine == null){ + this.racine = new Noeud(valeur); + } + else{ + Queue parcours = new LinkedList<>(); + Noeud noeudActuel; + parcours.offer(this.racine); + do{ + noeudActuel = parcours.poll(); + } while(noeudActuel.add(valeur, parcours) == false); + } + } + + public int[] toArray(){ + if (racine == null){ + return new int[0]; + } + + int[] resultat = new int[this.nbNoeud]; + Queue parcours = new LinkedList<>(); + int i; + + parcours.offer(this.racine); + + for (i=0; i parcours){ + if (this.gauche == null){ + this.gauche = new Noeud(valeur); + return true; + } + if (this.droite == null){ + this.droite = new Noeud(valeur); + return true; + } + parcours.offer(this.gauche); + parcours.offer(this.droite); + return false; + } + + public int getValeur(Queue parcours){ + parcours.offer(this.gauche); + parcours.offer(this.droite); + return this.valeur; + } +} \ No newline at end of file