From 5495b60332c7b5690abd3a04ce1442d1b155484b Mon Sep 17 00:00:00 2001 From: HORVILLE Ewen Date: Wed, 7 Sep 2022 15:35:41 +0200 Subject: [PATCH] =?UTF-8?q?TP1=20Termi,n=C3=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../{ => TP1}/Victoire/RefreshListener.class | Bin DEV 3.1/TP1/Victoire/RefreshListener.java | 14 ++++++ DEV 3.1/TP1/Victoire/Victoire.class | Bin 0 -> 2744 bytes .../Victoire/Victoire.java} | 45 ++++++++++++++---- DEV 3.1/TP1/Vote/Vote.class | Bin 0 -> 2423 bytes DEV 3.1/{ => TP1}/Vote/Vote.java | 13 ++++- DEV 3.1/Victoire/Victoire.class | Bin 1089 -> 0 bytes DEV 3.1/Victoire/Victoire.java | 33 ------------- DEV 3.1/Vote/Vote.class | Bin 2212 -> 0 bytes 9 files changed, 61 insertions(+), 44 deletions(-) rename DEV 3.1/{ => TP1}/Victoire/RefreshListener.class (100%) create mode 100644 DEV 3.1/TP1/Victoire/RefreshListener.java create mode 100644 DEV 3.1/TP1/Victoire/Victoire.class rename DEV 3.1/{Victoire/RefreshListener.java => TP1/Victoire/Victoire.java} (56%) create mode 100644 DEV 3.1/TP1/Vote/Vote.class rename DEV 3.1/{ => TP1}/Vote/Vote.java (77%) delete mode 100644 DEV 3.1/Victoire/Victoire.class delete mode 100644 DEV 3.1/Victoire/Victoire.java delete mode 100644 DEV 3.1/Vote/Vote.class diff --git a/DEV 3.1/Victoire/RefreshListener.class b/DEV 3.1/TP1/Victoire/RefreshListener.class similarity index 100% rename from DEV 3.1/Victoire/RefreshListener.class rename to DEV 3.1/TP1/Victoire/RefreshListener.class diff --git a/DEV 3.1/TP1/Victoire/RefreshListener.java b/DEV 3.1/TP1/Victoire/RefreshListener.java new file mode 100644 index 0000000..890f2ae --- /dev/null +++ b/DEV 3.1/TP1/Victoire/RefreshListener.java @@ -0,0 +1,14 @@ +import java.awt.*; +import java.awt.event.*; +import javax.swing.*; +import java.sql.*; + +public class RefreshListener implements ActionListener { + public RefreshListener() { + + } + + public void actionPerformed(ActionEvent e) { + Victoire.refresh(); + } +} diff --git a/DEV 3.1/TP1/Victoire/Victoire.class b/DEV 3.1/TP1/Victoire/Victoire.class new file mode 100644 index 0000000000000000000000000000000000000000..3a7614c18fafa96c6ffd1d8cbee0587286f67007 GIT binary patch literal 2744 zcmZuz`%@d&75)}U>`E-btPO_PNj7$z05X!3*p34xX%LXe7UChm#ZDiKbiqp`t-QO! zkT!iLO`q-~X`4Qiwn^PKO&dEMFkzwh2r9l&Y)ErxT*Xc&(niwPBzQA}Z4LoS9H%xaj^a7n|bW0=Qf6<0L8sNpj$_$)rx zg3rU!uppoL78D@lvM86OD4xRA7*4^KyX6>OLQx)+q;g3^S$cP*8@^OjT+`sjV8WA& zFPExZR#aTquo}ao@KmhD(2IOBL{Y(^%(As&ttP$ec6ljzA&?F#(DP2U?7M4qt>*J~+4i4N5bEij zQxHx$1)-oVW0ys?T3Qh9jI~gtM0LfYE4-@;T64aYe`(yR1SjN@gsFI4#Wz)aOU1Y8 zq-5D;1)V)t0tm^XMF2V9C5}NEB$jikZeEPp(sApYo%bEv6$uGf$9W7XIPADfiIU~o zR$(ErTv*5_MqGPEFw5`g_%6Puz?9lG v2d0EFFV`7ET)x4i7}fP|z=94AcV-B$I{fmb)UngkAOf7n#3RO)R>}tB$*3 z7bR$IciU{8S;{|sM#Y;tevF?e=m?N`*NVy9RAvW`g8OI7l1kHeOe>!ko@b6&zO`U^ zBB9{L+-PPrHDhL-(n&KnJKi(t*k#}AHOHnW#?3j$7iMO3Y{tAWk7M5BQ^wKjD2Hf5!U?4(_oTuKK>iYZdy>+aK|U zPS@^Z#`b(s7OsvD@Rx1!t?Pbr*l`QO%~)$r)mISVmGiIa_$xltaSOLU38>x;p+th| zoCgCar)ZURT%T9IIVH-zjPWT+!-3taH?gqH4C_dfvgWCsq*?Kun=t8$isgy|TgMkA zI@{x=)*5w4ftP9FRf~R3P_Jz_T5!?Xii?h$4fs3JvrmIHhynxld;{X#8u==bMd7-n ztEOx_$w_vnPawi7(I8+xxmV1<6{%EY4LbG<%+BuI$+*_9<5t;P5)9P3B>YBd#`kg1 z0K7gd?v?b`M0=T*8CGfxHxPVkpAZe^_mqTQTE(i!SA8*CDX>n#OiXiP)}>Qb;jYQC z*5GBQP_z!0#VQNNL3){2h6$%-ox?rpUOI{LeY?&b6y2K|`SpZ96ZmM~EjpcufI`i8 zwjD%*2Kz)AYIiXhuw8UCA{H&)p_FXJiHdM7*@!hbER+nDvtMS8k)Cu~4&@d~GETm( z)@~IF&jr1^-Czoi)d`i|C02NelY2FS&>^mnw*loAHwvER+FTRT zh>grWRh2E8HuLObqv;Mpmu{l<;%!8X=5?sI49$odu{&tFNO4ArTcxEQ^T z#8Hy_Ac=j5_9mX^=@gFP3jJ7k1j{&q5*|Z^7Av%P1#!HN$8iHsF#c0Sa2jvn4Bo+6 zA{ii-A)*=N06vdRvi}^>3_?$<7>;ICr2dPjijljF8sSsLsG?#_WmueO>by&!d>@fZ zs_g|X8k2Yd=~^N252hcYLw^hAyz%e`j%DJk;_-O9a+1GwJQ8omKlxk7i7h-jZ#=ev zp7E1g=$+p{-#X&)lLkwXh=#qW zd&LGwDVSIc!^E3HHvu2V82XvTIih`*ct>!NG-mj}FpDKjkiIE+m}VXqXxoH~{|AZ= BvmF2c literal 0 HcmV?d00001 diff --git a/DEV 3.1/Victoire/RefreshListener.java b/DEV 3.1/TP1/Victoire/Victoire.java similarity index 56% rename from DEV 3.1/Victoire/RefreshListener.java rename to DEV 3.1/TP1/Victoire/Victoire.java index 722071b..dff39d3 100644 --- a/DEV 3.1/Victoire/RefreshListener.java +++ b/DEV 3.1/TP1/Victoire/Victoire.java @@ -1,10 +1,13 @@ -import java.awt.*; -import java.awt.event.*; -import javax.swing.*; import java.sql.*; +import javax.swing.*; +import java.awt.*; -public class RefreshListener implements ActionListener { - public RefreshListener() { +public class Victoire { + + public static JLabel scoreLabel; + public static JLabel countryLabel; + + public static void refresh() { try { Class.forName("org.mariadb.jdbc.Driver"); } catch (ClassNotFoundException ex) { @@ -21,11 +24,11 @@ public class RefreshListener implements ActionListener { } try { - PreparedStatement req = cnx.prepareStatement("SELECT Competiteur, SUM(Points) FROM Vote GROUP BY Competiteur;"); + PreparedStatement req = cnx.prepareStatement("SELECT Nom, SUM(Points) FROM Vote LEFT JOIN Pays ON Vote.Competiteur = Pays.ID GROUP BY Nom;"); req.executeUpdate(); int maxPoints = 0; - String country; + String country = ""; ResultSet rs = req.executeQuery(); while (rs.next()) { int score = rs.getInt(2); @@ -35,6 +38,14 @@ public class RefreshListener implements ActionListener { } } + if (country != "") { + countryLabel.setText(country); + scoreLabel.setText(Integer.toString(maxPoints)); + } + + + + rs.close(); req.close(); @@ -50,7 +61,23 @@ public class RefreshListener implements ActionListener { } } - public void actionPerformed(ActionEvent e) { + public static void main(String[] args) { + JFrame window = new JFrame("Victoire"); + window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + window.setSize(300, 300); + window.setLocation(200, 200); + + JButton refreshBT = new JButton("⟳"); + refreshBT.addActionListener(new RefreshListener()); + window.add(refreshBT, BorderLayout.SOUTH); + window.setVisible(true); + + countryLabel = new JLabel("...", JLabel.CENTER); + scoreLabel = new JLabel("0", JLabel.CENTER); + + window.add(countryLabel, BorderLayout.NORTH); + window.add(scoreLabel, BorderLayout.CENTER); + Victoire.refresh(); } -} +} \ No newline at end of file diff --git a/DEV 3.1/TP1/Vote/Vote.class b/DEV 3.1/TP1/Vote/Vote.class new file mode 100644 index 0000000000000000000000000000000000000000..d4ad17a76bed6c54ecb56baa01b5ac60c4ea6620 GIT binary patch literal 2423 zcmZ`*TUQfT6#h;KnMoKL4F(K&8ByDCN#YGE;1viJn*<~%Ra@&MImE$aCeBO{dcWAa zYxT8#^~IOI=mSbG{(%05uGPo>h<4TPGYLst(s|f(&OUp8`+D}w@BjY%48RH84GRj9FGstI@Lq6O>p5tGG+4Rj`J2 z1@GZ~1s~u;%Cv%y@UenV@Tr2&FvxJD4oUjM>b$8Nj$OkR1yEDTnML*D+-#<1YA&O? zbs?e&!P71~PVUs4m@>;1?&uD$T6Jd>e2#kxz7VDBX(qqc86Gm-g{X>;lt!{B*Q zWXhyh#KEwm>C#+og-#i|8iko^C=hp>&SvOs$j)25qFKB^jqdO=HwY-yI9%X%wd72zKQ3r>k+uy=qGg!Cz zNoU!#GFq7uad1KEukn1<;g>4~DyBR9W*L+^_fnNx z>q5K5RHMLT!fWs~Dl|>ZYh;hIvSlwEovo|1jz@-ew>@dtlI*N#94`ry!8Wr>8=qFG zaCi9pf3z)l^(#ew?Agv-^H_GwEys3kh0=mU057yr?RL;G#{s-XUoP=@z{G4OIz+p@ z^k(#KAAAD#h!zaPM13x^4SvKBr!|Rsitr*p0waUZybqu}h9}gv0q>(w`&0Oq9-=cP zShCCVhXSFFr%+PFP7C%cf;|)pZeoWA>0$3++p$gTY{T#-LJUjv>SD;mHnEF#G4CeA z9*lcw-%Z9tJ+9h#d!*ePp)=BpwAU2dMtx#Q%HvW*a@BvtxrkIpkRuYE?)G5RANGa) zH%EPs5%~qZSD&CSLay!!?IjZSZ(!dB_LGkfpZ`h{A(fU*$pLK^FUP4f~-%#R_Ru zaF9MHhj0&vai2Qjd+LQBs0$uYAN)kc-Jml6MreN!+MhUvzi^x}j4&CaEQks6@+9jb zfBP`b`f-Luah^Or%Z71|ogk|TYMBe@2+|MF5r0a;(SP8VaO^p5K$dWvmJ&`#pbzON eEf}qUzcKTiOnGYOAm&k_e^jP+d!6t+IQbu)TTJT! literal 0 HcmV?d00001 diff --git a/DEV 3.1/Vote/Vote.java b/DEV 3.1/TP1/Vote/Vote.java similarity index 77% rename from DEV 3.1/Vote/Vote.java rename to DEV 3.1/TP1/Vote/Vote.java index 11cade7..4c6910b 100644 --- a/DEV 3.1/Vote/Vote.java +++ b/DEV 3.1/TP1/Vote/Vote.java @@ -23,8 +23,17 @@ public class Vote { } try { - PreparedStatement req = cnx.prepareStatement("SELECT Votants, Points FROM Vote WHERE Competiteur = (?);"); - req.setString(1, args[0]); + PreparedStatement nameReq = cnx.prepareStatement("SELECT ID FROM Pays WHERE Nom = (?);"); + nameReq.setString(1, args[0]); + nameReq.executeUpdate(); + + ResultSet rs1 = nameReq.executeQuery(); + rs1.next(); + String nom = rs1.getString(1); + rs1.close(); + + PreparedStatement req = cnx.prepareStatement("SELECT Nom, Points FROM Vote LEFT JOIN Pays ON Vote.Votants = Pays.ID WHERE Competiteur = (?);"); + req.setString(1, nom); req.executeUpdate(); int total = 0; diff --git a/DEV 3.1/Victoire/Victoire.class b/DEV 3.1/Victoire/Victoire.class deleted file mode 100644 index 4ef279455799ef41cd20fbaa143e1ca1578bd957..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1089 zcmZuv?M@Rx6g@*fcDpP>7g|0975r-1(xRdwMG=ZsaDga>q?(v)+X0reU9!6c@nw7l zA!&_Gj6aQ!;e#0OY)b@XGkfoyn{(%$duD$A{`w8T3^o*uA}L`~hOVFsDPg9BNeh#a zFfHSb0vRa@cNKIaDK_^c%*ePeAPNG&t@6al3lNP&QS*yp0{e2_kng6|3Im%~F(!i0y6t!*L^#K5p6GT%4Atj%^TpUG?(q^eiX|>qXvpQ>GT%1q6)#t@ zUB0o;9n-VKK*7X{&`=`8ruC6z2_;tiOgCi=yVQY2&2o9MBuY+aW|-)769e-DqLw+2 z@GmDog$&6v(41Y}w`&B?o*~(h+ zh|rFF08HFH*$LW>k!R#XlTEPC6fj&T8*V45h!mw*K!@oU-+wTbU^j8A1N)93^#HsU zx(ZsLiJ+l}8wlx9mZH@_SdZcdtp=nPA?n~EocR; zpAH!~LCoL8+nYiC7%^=~;Epk<4O8$1BYy{&!zJR-3k7{-qeNb#!3Hpe7-kX20tT^6 Z*;g3Bds1qLl-MVQT+)W&Hq~|^@dsSb=coVx diff --git a/DEV 3.1/Victoire/Victoire.java b/DEV 3.1/Victoire/Victoire.java deleted file mode 100644 index c95cff4..0000000 --- a/DEV 3.1/Victoire/Victoire.java +++ /dev/null @@ -1,33 +0,0 @@ -import java.sql.*; -import javax.swing.*; -import java.awt.*; - -public class Victoire { - - public static JLabel scoreLabel; - public static JLabel countryLabel; - - public static void refresh() { - - } - - public static void main(String[] args) { - JFrame window = new JFrame("Victoire"); - window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); - window.setSize(300, 300); - window.setLocation(200, 200); - - JButton refreshBT = new JButton("⟳"); - refreshBT.addActionListener(new RefreshListener()); - window.add(refreshBT, BorderLayout.SOUTH); - window.setVisible(true); - - countryLabel = new JLabel("...", JLabel.CENTER); - scoreLabel = new JLabel("0", JLabel.CENTER); - - window.add(countryLabel, BorderLayout.NORTH); - window.add(scoreLabel, BorderLayout.CENTER); - - Victoire.refresh(); - } -} \ No newline at end of file diff --git a/DEV 3.1/Vote/Vote.class b/DEV 3.1/Vote/Vote.class deleted file mode 100644 index 8534ac61b8c124d2b285d33cc03edb1d958373a6..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2212 zcmZ`)OLG%P5dKD5Ygh6bfsAZyUTa>ljV&310oz~_zk(CV*p`jMD`6###Tsc>-iNV6 z-tS+Ks+>~Ag{s`(U~p2!B{xn~CCA)yN>y@9s!~Zode#q#py)6&>goQv`|F3*A$#rFkX+>@kTvT zNQ-4cEEnoAi7By6izOpKXJpJqunVWea#6vY*xwY(B?XriToIaAh4obh*M$4G1Ty`3 zTgG)6Iz#A;VH)lrL$JN$B7-z+z}8p1YaW%f3D(N4dzz%E-yc%OHeE#`5eOA2S48_@d?Vgg{c!jt&{~ zDhjy4uw%l~a+YVh_KH?8mbjUaVW?QZO@?O6E+k62ZRq)IVj-W+B}Qygv1JrhltAHW zmDq-hy5me(?ihjPN0)QF>>3uS>`DuOks&Sb+iIreYV$&ep<7_~Z#d{rCiAy+dx<*< z!*jdmi3QzD%-hKumc3*YMG{Ko7}9$SxxQW*mWnbK8RC8<&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