From 0c873faeb2c4e82fa2dff01a2e2038259d395df9 Mon Sep 17 00:00:00 2001 From: pourchot Date: Mon, 27 Mar 2023 11:28:45 +0200 Subject: [PATCH] 27 Mars --- DEV2.1/TP5:MiseEnPageEtDessin/Sautoir.class | Bin 0 -> 879 bytes DEV2.1/TP5:MiseEnPageEtDessin/Sautoir.java | 19 ++++++++++++--- DEV2.1/TP6 | 0 DEV2.1/TP6:Polymorphisme/MainVehicule.class | Bin 0 -> 1417 bytes DEV2.1/TP6:Polymorphisme/MainVehicule.java | 22 +++++++++++++++++ DEV2.1/TP6:Polymorphisme/Moto.class | Bin 0 -> 217 bytes DEV2.1/TP6:Polymorphisme/Moto.java | 5 ++++ DEV2.1/TP6:Polymorphisme/Moyenne.class | Bin 0 -> 918 bytes DEV2.1/TP6:Polymorphisme/Moyenne.java | 23 ++++++++++++++++++ DEV2.1/TP6:Polymorphisme/Vehicule.class | Bin 0 -> 160 bytes DEV2.1/TP6:Polymorphisme/Vehicule.java | 4 +++ .../TP6:Polymorphisme/VehiculeAbstract.class | Bin 0 -> 463 bytes .../TP6:Polymorphisme/VehiculeAbstract.java | 18 ++++++++++++++ DEV2.1/TP6:Polymorphisme/Voiture.class | Bin 0 -> 223 bytes DEV2.1/TP6:Polymorphisme/Voiture.java | 5 ++++ 15 files changed, 92 insertions(+), 4 deletions(-) create mode 100644 DEV2.1/TP5:MiseEnPageEtDessin/Sautoir.class create mode 100644 DEV2.1/TP6 create mode 100644 DEV2.1/TP6:Polymorphisme/MainVehicule.class create mode 100644 DEV2.1/TP6:Polymorphisme/MainVehicule.java create mode 100644 DEV2.1/TP6:Polymorphisme/Moto.class create mode 100644 DEV2.1/TP6:Polymorphisme/Moto.java create mode 100644 DEV2.1/TP6:Polymorphisme/Moyenne.class create mode 100644 DEV2.1/TP6:Polymorphisme/Moyenne.java create mode 100644 DEV2.1/TP6:Polymorphisme/Vehicule.class create mode 100644 DEV2.1/TP6:Polymorphisme/Vehicule.java create mode 100644 DEV2.1/TP6:Polymorphisme/VehiculeAbstract.class create mode 100644 DEV2.1/TP6:Polymorphisme/VehiculeAbstract.java create mode 100644 DEV2.1/TP6:Polymorphisme/Voiture.class create mode 100644 DEV2.1/TP6:Polymorphisme/Voiture.java diff --git a/DEV2.1/TP5:MiseEnPageEtDessin/Sautoir.class b/DEV2.1/TP5:MiseEnPageEtDessin/Sautoir.class new file mode 100644 index 0000000000000000000000000000000000000000..c086cf00c008207b004649300816451be85ee4dd GIT binary patch literal 879 zcmZuw?Q+sk5IvV91i~#JwXH_2TKob^L949_wSF+8;^*n0dv?#>n_qvv{RFU%yBZQWso^+IX^7*rFpFY)Mxe98 zoD#8lW4o9;ZcM0ne2b0F+{9k zePFyBQ3ws|1u5;C-hI;Ab)AvjVVIpxtT=tgEmPLeq_GiZI5su1!_Q(~5n_36b-Z3c zTV;rnowW=`!f@t;|X_fvCh7$pk{ue0_wOjxI literal 0 HcmV?d00001 diff --git a/DEV2.1/TP5:MiseEnPageEtDessin/Sautoir.java b/DEV2.1/TP5:MiseEnPageEtDessin/Sautoir.java index 13ce3b2..66dac1c 100644 --- a/DEV2.1/TP5:MiseEnPageEtDessin/Sautoir.java +++ b/DEV2.1/TP5:MiseEnPageEtDessin/Sautoir.java @@ -4,7 +4,18 @@ import java.awt.*; public class Sautoir extends JComponent{ protected void paintComponent(Graphics pinceau) { - // obligatoire : on crée un nouveau pinceau pour pouvoir le modifier plus tard - Graphics pinceau = pinceau.create(); - pinceau.setColor(Color.CYAN); - pinceau.fillPolygon([0,0],[50,0],3); \ No newline at end of file + // obligatoire : on cree un nouveau pinceau pour pouvoir le modifier plus tard + Graphics pinceau2 = pinceau.create(); + if (this.isOpaque()) { + // obligatoire : on repeint toute la surface avec la couleur de fond + pinceau2.setColor(this.getBackground()); + pinceau2.fillRect(0, 0, this.getWidth(), this.getHeight()); + } + pinceau2.setColor(Color.CYAN); + int[] x={0, getWidth()/2, getWidth()}; + int[] yt={0, getHeight()/2, 0}; + pinceau2.fillPolygon(x,yt,3); + int[] yb={ getHeight(), getHeight()/2, getHeight()}; + pinceau2.fillPolygon(x,yb,3); + } +} diff --git a/DEV2.1/TP6 b/DEV2.1/TP6 new file mode 100644 index 0000000..e69de29 diff --git a/DEV2.1/TP6:Polymorphisme/MainVehicule.class b/DEV2.1/TP6:Polymorphisme/MainVehicule.class new file mode 100644 index 0000000000000000000000000000000000000000..2a49f9030f0472a91eb297c4822ef8f2ddba90fe GIT binary patch literal 1417 zcmaJ>O>+}R5Pc)bn)Q0YShhnFu#p`TBrp~vgb)OVATS6dOd{fxE2ptMWi4LKsCGwo z%rBv+$~oZ(2R;if-14IcJ<@{Lpo*$AA3fc#-*ms7f8V`)1K=!{U8Hb?Bky3w!K{OC z9L#YXb;0p1$Bc_%dpzr61V@H(422OKM$rz(bA+(qqJ&c%rx~&reC3-(hIFC0!jP%x zb;&SV^Od~aZLi7ju2>7ml4%QHF?><@qjpbhiBcfcMyX*!Uu~3a;J$_t&CR;#^!z!# z4r9UT^r4i z|D`K~{MOq?{qTIVrTxf{B6JECw0{qf!<&+g??qlwkcI~yQ7s$kl4k_TjSC zrdH(vv=V_aRI$3J@{OIy$Tmqqcd7o9eScqayXs9a_g<=Bn<0ZLT z`&CmHdWx#LxP~Qa#&1gIS-zvA=ZDa`M_Y0)Y&LKzA_7S|)G zwCcc=<2~{0B})3~SlR(eVR8UcafRc$ZS5_Fxn1%3YD;g*SlE49OQLCXxWiGWucfB- zX17Bss46AHN+3vn#PvZkLyXZ^(G8*20~yWr1C#BHE0(C?p1`|19XY^#KwpzJi6JT? z2pYbTWschnM?bsYAZ`rP|L=zxl_chDr%W-3#9PA~_s2ZLah2Mcf5nRK5WlEkZkzXO)zxT*NnBh(r^*gY~8Y!&GFaaIXuMou_^UvU)IBO{Od+>g)}8KXDEx%>V!Z literal 0 HcmV?d00001 diff --git a/DEV2.1/TP6:Polymorphisme/Moto.java b/DEV2.1/TP6:Polymorphisme/Moto.java new file mode 100644 index 0000000..f1ff095 --- /dev/null +++ b/DEV2.1/TP6:Polymorphisme/Moto.java @@ -0,0 +1,5 @@ +public class Moto extends VehiculeAbstract{ + public Moto(){ + super(2,"Moto"); + } +} \ No newline at end of file diff --git a/DEV2.1/TP6:Polymorphisme/Moyenne.class b/DEV2.1/TP6:Polymorphisme/Moyenne.class new file mode 100644 index 0000000000000000000000000000000000000000..9bef0cd72314552e0e16c6fbd3bf987b1c625ece GIT binary patch literal 918 zcmZuv+int36kUhglwr8^0#@;c+R86i$~Vefs`UVH7u`Tgg|F97SL#%D7|Tu0YsxJ=qlyRe@lu?=gBU5ZSaH+k3`RzR(Z| zy>#13AX&2=wL9!J)!?mcc3BC^c3U8wuN}ydEO({TDNpY!y3On;@5M+BWJg2u1&)Z< zJ=yxOBl|OgP*2*9KqmjrM^X0%w$qtX)ZO8rrC!;3nziE|D#uZ4dYXkLq%EW{Z(#w8 z2JTt7kF0<(Lm7Br;UU&7EaSX^M>^Rs@Yuo=R4iOT*1)EPr{J2YGyQwb1J$ApzS49h zfmquea_xrf4yncms7~q}Jf^VZKpdv7THfY=NR7VZ;^4oswtWL0RLjCZg zr+ReJ9a39*N^QI4H+0IQUrP4ausC7=w@g)i4eHY75LGph;|oagbp-gOeUpd|@;3yb zUFE4CP#Hl+K(crOQA`{oP>dcU_?0Drb379S=r}~8=mbosXU!WN65#D}asN94r7=P+ zO~52*%KxxL5Qjn5Irj6fnXzn5BmtQs`=Xz}Ae=a27|`h__lW!fpOP3=Scp;AMcz=n zE?mOp8QCsNTGHxIg!fMnsg;&soFY1gSxT9wh%xvEi(2DjB+k~%a24>4&C#O;`je$Y MD|ATU%0$4`zsyIeuK)l5 literal 0 HcmV?d00001 diff --git a/DEV2.1/TP6:Polymorphisme/Moyenne.java b/DEV2.1/TP6:Polymorphisme/Moyenne.java new file mode 100644 index 0000000..a0f3f05 --- /dev/null +++ b/DEV2.1/TP6:Polymorphisme/Moyenne.java @@ -0,0 +1,23 @@ +public class Moyenne{ + private double total=0; + private long cpt=0; + + public void add(Number val){ + total += val.doubleValue(); + ++cpt; + } + + public double getAverage(){ + if (cpt==0){ + return 0; + } + return total/cpt; + } + + public static void main(String[] args) { + Moyenne m = new Moyenne(); + m.add(5.5); + m.add(10); + System.out.println(m.getAverage()); + } +} \ No newline at end of file diff --git a/DEV2.1/TP6:Polymorphisme/Vehicule.class b/DEV2.1/TP6:Polymorphisme/Vehicule.class new file mode 100644 index 0000000000000000000000000000000000000000..a9f0cdbd417e05551cfd661ed402b84fcc328a29 GIT binary patch literal 160 zcmX^0Z`VEs1_m<*ZgvJvb_Om+2KKz9p#0L*VnzmL4NXr*2G-*IqLNfb1`!QSpRB~P zME#t^ymbBGlA_GKbZbTiuHgLAqU2P!%p9N^-muh+%;eIXR6USNMg|TTpOHZTq1Qht nD>b=tqiNdM*4ow=F5I=D*oELm5kwFQMZrq*1MoCaxj?wxX`O2TD zAQcpUQi};j#y%f!f-ix_MH+uc%Ym#q{W2Wt8h3~Eb=Io;3UPPm(A@4E`ZFy-g<2;H w1R2EG1XZZ~O;o=Dd#u8Q>ApaF{B0{N%={J`HEMp>|ET`76wO2H^fc7J061<>S^xk5 literal 0 HcmV?d00001 diff --git a/DEV2.1/TP6:Polymorphisme/VehiculeAbstract.java b/DEV2.1/TP6:Polymorphisme/VehiculeAbstract.java new file mode 100644 index 0000000..b1e7065 --- /dev/null +++ b/DEV2.1/TP6:Polymorphisme/VehiculeAbstract.java @@ -0,0 +1,18 @@ +public abstract class VehiculeAbstract implements Vehicule{ + + private int nbRoues; + private String sorte; + + public VehiculeAbstract(int nbRoues, String sorte){ + this.nbRoues=nbRoues; + this.sorte=sorte; + } + + public int nbRoues(){ + return nbRoues; + } + + public String sorte(){ + return sorte; + } +} \ No newline at end of file diff --git a/DEV2.1/TP6:Polymorphisme/Voiture.class b/DEV2.1/TP6:Polymorphisme/Voiture.class new file mode 100644 index 0000000000000000000000000000000000000000..e041b8046d30289bd5a236ca984e71296b480d09 GIT binary patch literal 223 zcmXYrPiw+J5XIl*kDDf`5f9!44~d87){CVeLO}>#l-xIQu`6i;+l}9=r$P_?0DdUx zq&Nfb&3pU~bG`li0(eFeAPV6j7Kj8M38NR?YWqrX)2t+To9?IxNugV{>pv=G4zg;v z3HM!ZYW1dv5SN{{y-`nRd65Khk1>3V36oO2>$-2$y85(6)|N0!x5dEbjciZ(-WuJW rR#}NTTz+O4;`K3N6`U5_6ML`}Q~HMU^-lz>AskkhDUXQrONJ_Q literal 0 HcmV?d00001 diff --git a/DEV2.1/TP6:Polymorphisme/Voiture.java b/DEV2.1/TP6:Polymorphisme/Voiture.java new file mode 100644 index 0000000..f81b227 --- /dev/null +++ b/DEV2.1/TP6:Polymorphisme/Voiture.java @@ -0,0 +1,5 @@ +public class Voiture extends VehiculeAbstract{ + public Voiture(){ + super(4,"Voiture"); + } +} \ No newline at end of file