From f24050cb7ea9b912bde229433d81558516932be4 Mon Sep 17 00:00:00 2001 From: HORVILLE Ewen Date: Tue, 8 Feb 2022 17:20:59 +0100 Subject: [PATCH] TP03 fin ; TP04 --- APL2.1/TP03/Piege/Piege.class | Bin 0 -> 1024 bytes APL2.1/TP03/Piege/Piege.java | 44 ++++++++++++++++++++++ APL2.1/TP03/Rose/Rose.class | Bin 0 -> 1205 bytes APL2.1/TP03/Rose/Rose.java | 30 +++++++++++++++ APL2.1/TP04/Date/Date.class | Bin 0 -> 491 bytes APL2.1/TP04/Date/Date.java | 6 +++ APL2.1/TP04/Date/MyDate.class | Bin 0 -> 606 bytes APL2.1/TP04/Date/MyDate.java | 33 ++++++++++++++++ APL2.1/TP04/Lendemains/Lendemains.class | Bin 0 -> 553 bytes APL2.1/TP04/Lendemains/Lendemains.java | 10 +++++ APL2.1/TP04/Lendemains/MyDate.class | Bin 0 -> 1048 bytes APL2.1/TP04/Lendemains/MyDate.java | 37 ++++++++++++++++++ APL2.1/TP04/Periode/MyDate.class | Bin 0 -> 1048 bytes APL2.1/TP04/Periode/MyDate.java | 37 ++++++++++++++++++ APL2.1/TP04/Periode/MyPeriod.class | Bin 0 -> 1177 bytes APL2.1/TP04/Periode/MyPeriod.java | 31 +++++++++++++++ APL2.1/TP04/Periode/Periode.class | Bin 0 -> 575 bytes APL2.1/TP04/Periode/Periode.java | 9 +++++ APL2.1/TP04/Progression/Compteur.class | Bin 0 -> 450 bytes APL2.1/TP04/Progression/Compteur.java | 16 ++++++++ APL2.1/TP04/Progression/Progression.class | Bin 0 -> 576 bytes APL2.1/TP04/Progression/Progression.java | 10 +++++ 22 files changed, 263 insertions(+) create mode 100644 APL2.1/TP03/Piege/Piege.class create mode 100644 APL2.1/TP03/Piege/Piege.java create mode 100644 APL2.1/TP03/Rose/Rose.class create mode 100644 APL2.1/TP03/Rose/Rose.java create mode 100644 APL2.1/TP04/Date/Date.class create mode 100644 APL2.1/TP04/Date/Date.java create mode 100644 APL2.1/TP04/Date/MyDate.class create mode 100644 APL2.1/TP04/Date/MyDate.java create mode 100644 APL2.1/TP04/Lendemains/Lendemains.class create mode 100644 APL2.1/TP04/Lendemains/Lendemains.java create mode 100644 APL2.1/TP04/Lendemains/MyDate.class create mode 100644 APL2.1/TP04/Lendemains/MyDate.java create mode 100644 APL2.1/TP04/Periode/MyDate.class create mode 100644 APL2.1/TP04/Periode/MyDate.java create mode 100644 APL2.1/TP04/Periode/MyPeriod.class create mode 100644 APL2.1/TP04/Periode/MyPeriod.java create mode 100644 APL2.1/TP04/Periode/Periode.class create mode 100644 APL2.1/TP04/Periode/Periode.java create mode 100644 APL2.1/TP04/Progression/Compteur.class create mode 100644 APL2.1/TP04/Progression/Compteur.java create mode 100644 APL2.1/TP04/Progression/Progression.class create mode 100644 APL2.1/TP04/Progression/Progression.java diff --git a/APL2.1/TP03/Piege/Piege.class b/APL2.1/TP03/Piege/Piege.class new file mode 100644 index 0000000000000000000000000000000000000000..83e4ecdd553ca0b4ed6676958c0489f22e2113fc GIT binary patch literal 1024 zcmZuvOHUI~7(KV0SBC+nVtFagM3e+m9sz?v7G`M2W=K0j+9@b5P5cA? z0snvt7nVd4m&Ukp<;tBqcW&HZV*Kuuq?p+Bo_p?h&;7n{&b^=iy#D}T21_bBaYIJ0 zf<6@?^m7>CFvwwu!?27I1#uM-^eadxNGdQDjPd|UBXwztOUF2*WsJ+X$so-;uH!E< zgyV@F24UID+YGH)$FN?GgW-)mR_Ld04RYEBU3iL9%ag8`h*$ePB@cRs*-B|b( zLe`A3QTo>)ntEQ(*C3fv4YJ8zNw#l%C-$h0^P(dOTc1)DSLd451;48e(Ii8)BGei5gNApC~2AAeABM znPA7H{$mf#RDgz1pTzn^Uqf3|uFa&4_J%=6<7lQQ*MfU! z#U^y@A%@3jLyqpiBk!M+`!C7nS7h#M%JT+2c!yqmqzqp$fUg+DHw@uBW&42<{6qr3 Oki$*)@x(znUkF@TVF<^sr3`Rz~7N;Ha)XDIGZXB<=Be5gL z-Pk1Fc;z490Zr4SJ|m=5S_Qlzg!VH28zjUy*PXa66yt$I8t}pMV+qq^^d<~y6 zIR77ufw%7t^Gx<=l&v&CM#JS(dJjvL?$@{$oJ#hg)e;7iK9rR3}#!>c2p%$ zSsF!z930t~otR3`KEFqxw`rxxkUHf<8$MQTw6$5shK;NE?7*NKom+846HL88REApP z#ZvQOoCoS2ZDKZ7SGD+Kg!pMBbCuG-hv{@VzA3kRd8QU^C8g6&--fvfE`?c&=tE?GMs~ za+c=z*U^ps1L)x-XauyI?<(!-xu4 z1!$mxS20KaaSGgkK{)W|9!jBG-i6_NlWcJkzmH&gPS@#r%RSV> zlQrYaE@sY~HNzTw54&!fBOKnrtUep}HBc^qO5Nn-5d1)c#t8KtOw6>Rz2v zXK#FKu$`y(Jt7>@dzXs6*Wec0SHUq&e+x%RffE>m2OFm`j+<~Wz$CsQ-glV755#(i z8T^Eo@GI*0jpC0f>j??_8daJDe+mVY<8_V_haiXK{u^@~HOCwu`-=)QyipAB=D(^d B1}p#o literal 0 HcmV?d00001 diff --git a/APL2.1/TP03/Rose/Rose.java b/APL2.1/TP03/Rose/Rose.java new file mode 100644 index 0000000..65f5eed --- /dev/null +++ b/APL2.1/TP03/Rose/Rose.java @@ -0,0 +1,30 @@ +import javax.swing.*; +import java.awt.*; + +public class Rose { + public static void main(String[] args) { + JFrame fenetre = new JFrame("Rose"); + fenetre.setSize(300, 200); + fenetre.setLocation(100, 100); + fenetre.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + + GridLayout grid = new GridLayout(3, 3); + fenetre.setLayout(grid); + + String[] nameList = new String[] {"Mystral", "Tramontane", "Grec", "Ponant", "", "Levant", "Libeccio", "Marin", "Sirocco"}; + + for (int i = 0; i < 9; i++) { + JLabel label = new JLabel(nameList[i]); + if (i % 3 == 0) label.setHorizontalAlignment(SwingConstants.LEFT); + else if (i % 3 == 1) label.setHorizontalAlignment(SwingConstants.CENTER); + else label.setHorizontalAlignment(SwingConstants.RIGHT); + + if (i < 3) label.setVerticalAlignment(SwingConstants.TOP); + else if (i > 5) label.setVerticalAlignment(SwingConstants.BOTTOM); + + fenetre.add(label); + } + + fenetre.setVisible(true); + } +} \ No newline at end of file diff --git a/APL2.1/TP04/Date/Date.class b/APL2.1/TP04/Date/Date.class new file mode 100644 index 0000000000000000000000000000000000000000..d21534356c18abee38851d310899936275ad14ad GIT binary patch literal 491 zcmZWmOG`pQ6#nMktE0D@X+F}*%4%^f$Yq4lrU(RkfFVSy(FVD4A7NwQ&#Hw&K|i2n zKPWn*3kzp)Uh{qDd}rqC=lv7FG4^dFkl|RhVIZ4C4tX6FY^Ub`?A2Oo;Dx=qCfcoNIOxht zPlJ;eLdheIbC85hQ?5q3q_YiY{Ll>~!3JA_ITYZG74{?=G^c zZB)SNZS^rg>%u0xL|K_UBOg1MfW1<{;E;_^iyF9$6vY~Pf*6s3(g%$D4F67~%M+N* cH&};b#Kwrv=_!~5G>K}VNHqE%$_=D{0Tp~CDtTf0>0F#KHcY>s?$%;_m2R!;pI@WF_}jmQx2x_HDfaw%sQCEHwPN#Z7c{F z9VHV15eS&AI7%-C^t$W_2@oys=eZD{pM}L15%# z)KTq9ou@7w6l^TISi-Uk7X=qzvdoH$GFDv_@tw2!T?Ixz>Vqg%4MltQwQRQ4(S<a)z`T@*!X=*x>q^DA~&z`XLKUXkZGBZUZj;? z3gPJhCK=!rh4ldKRQLZwzk^XdHOR~!Gs&!s-NF9Hw{%XldUZCjh%sW;ZI9Co q#&Q1^Ie(@L-Jk8k^yj*;Zr&?PoC&Hks3%W#LtOG0k^j%UhKU!MestUb literal 0 HcmV?d00001 diff --git a/APL2.1/TP04/Date/MyDate.java b/APL2.1/TP04/Date/MyDate.java new file mode 100644 index 0000000..7caddb0 --- /dev/null +++ b/APL2.1/TP04/Date/MyDate.java @@ -0,0 +1,33 @@ +public class MyDate { + private int year; + private int month; + private int day; + + private int[] monthDurations = new int[] {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; + + public String toString() { + return String.format("%04d-%02d-%02d", year, month, day); + } + + public MyDate tomorrow() { + MyDate newDate = new MyDate(this.year, this.month, this.day+1); + + if (newDate.day > monthDurations[newDate.month-1]) { + newDate.day = 1; + newDate.month += 1; + } + + if (newDate.month > 12) { + newDate.month = 1; + newDate.year += 1; + } + + return newDate; + } + + public MyDate(int y, int m, int d) { + this.year = y; + this.month = m; + this.day = d; + } +} \ No newline at end of file diff --git a/APL2.1/TP04/Lendemains/Lendemains.class b/APL2.1/TP04/Lendemains/Lendemains.class new file mode 100644 index 0000000000000000000000000000000000000000..6521b6ccf14ea54a0bd85fa07a710d09d5d8cc3d GIT binary patch literal 553 zcmY*VO;5r=5Pb`Ul~M&nP*FfsvhPeJ@bj??@*fZ@;vE~jeyHl2hYRwr9 zTH?l%o!G^DY|kx-s9PoNLfk^hU0Z3|8pe@_9hhBS==GC`rf&eJ4|}H*y$O$@*tW zMkQ+qkuRxj_~0cx`-JB)!hgbAI6Z~e_#al^q2wp<5ftW-C-hIi7wQSp2Wf?%AVq!_ Q90eM%ME&Su^yfk34*{WUH~;_u literal 0 HcmV?d00001 diff --git a/APL2.1/TP04/Lendemains/Lendemains.java b/APL2.1/TP04/Lendemains/Lendemains.java new file mode 100644 index 0000000..a310bf7 --- /dev/null +++ b/APL2.1/TP04/Lendemains/Lendemains.java @@ -0,0 +1,10 @@ +public class Lendemains { + public static void main(String[] args) { + MyDate date = new MyDate(2002, 12, 31); + MyDate tomorrow = date.tomorrow(); + + System.out.println(date); + System.out.println(tomorrow); + System.out.println(date.isEqual(tomorrow)); + } +} \ No newline at end of file diff --git a/APL2.1/TP04/Lendemains/MyDate.class b/APL2.1/TP04/Lendemains/MyDate.class new file mode 100644 index 0000000000000000000000000000000000000000..79988c114473cc380aeeccf80e502e5fef135e78 GIT binary patch literal 1048 zcmZWo+fEZv6kTVo?R0>lD$1qYE7Mjkq6sk=Ln4^e0F9|3jzq&i2OMlWI!rPAg3o>c z4<^3&pos+H?F0NKW88bDNE2W7S!bPn)?Ry`nO}dt{sgdqTPcj_7)>LEF$3e6U^K}g zZ{Rwnbl3)M3d|G@NGJ&?N1huBh_Zm%2%6Cg0lDTL33SK1e!`*!IH5?slCRy4ncBFnA+i(ABl0 zWjFHZLRU3%cV4c!uiAOKf3Whp<<vJ1gs0ImF<0RCo*B8OUDfp)0i>QjV=>C%*>jY!%Zra2$~qg zkO>RDjOGP;FOc3}f!^r8}d0}4fIi;%<}#Va)xuhc=DA&|u-(EHJD2`VAL&I;`ZBu6fO zfqVv~>L`TN7^#FbMrY7JQLexhiduXxO|cJGDYDu-V%f!`Z%8?;#2S2C**ZmfwM2+^ z2Cb@6n|Y6HNjZU5a(KUW0+kOev(2l_%goCqE-S@l$Ei_JLw)pCHa*HTHMKy+m*{kb z*b4e_jWW`Zeq%vLioNw?pzZJ>$*{vIc1PvpW8~N*S3X9Ty%N-pp(`Jt$R8;+shhN$ zi?vlq`6c>g_`_)HzNI-Tl>EGSicHZmzZ;HhjZ_@P8mc%dBh4DFI69*gBTHjw#e|hG z>6kI%(+uGg7{x*AzBojqDduQWpQ%DJ{Q;UZFiJHwtkdgP>2H662|U9jW#nSp!+!yT C6~GAq literal 0 HcmV?d00001 diff --git a/APL2.1/TP04/Lendemains/MyDate.java b/APL2.1/TP04/Lendemains/MyDate.java new file mode 100644 index 0000000..b3bdb04 --- /dev/null +++ b/APL2.1/TP04/Lendemains/MyDate.java @@ -0,0 +1,37 @@ +public class MyDate { + private int year; + private int month; + private int day; + + private int[] monthDurations = new int[] {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; + + public String toString() { + return String.format("%04d-%02d-%02d", year, month, day); + } + + public MyDate tomorrow() { + MyDate newDate = new MyDate(this.year, this.month, this.day+1); + + if (newDate.day > monthDurations[newDate.month-1]) { + newDate.day = 1; + newDate.month += 1; + } + + if (newDate.month > 12) { + newDate.month = 1; + newDate.year += 1; + } + + return newDate; + } + + public boolean isEqual(MyDate date) { + return (this.year == date.year && this.month == date.month && this.day == date.day); + } + + public MyDate(int y, int m, int d) { + this.year = y; + this.month = m; + this.day = d; + } +} \ No newline at end of file diff --git a/APL2.1/TP04/Periode/MyDate.class b/APL2.1/TP04/Periode/MyDate.class new file mode 100644 index 0000000000000000000000000000000000000000..79988c114473cc380aeeccf80e502e5fef135e78 GIT binary patch literal 1048 zcmZWo+fEZv6kTVo?R0>lD$1qYE7Mjkq6sk=Ln4^e0F9|3jzq&i2OMlWI!rPAg3o>c z4<^3&pos+H?F0NKW88bDNE2W7S!bPn)?Ry`nO}dt{sgdqTPcj_7)>LEF$3e6U^K}g zZ{Rwnbl3)M3d|G@NGJ&?N1huBh_Zm%2%6Cg0lDTL33SK1e!`*!IH5?slCRy4ncBFnA+i(ABl0 zWjFHZLRU3%cV4c!uiAOKf3Whp<<vJ1gs0ImF<0RCo*B8OUDfp)0i>QjV=>C%*>jY!%Zra2$~qg zkO>RDjOGP;FOc3}f!^r8}d0}4fIi;%<}#Va)xuhc=DA&|u-(EHJD2`VAL&I;`ZBu6fO zfqVv~>L`TN7^#FbMrY7JQLexhiduXxO|cJGDYDu-V%f!`Z%8?;#2S2C**ZmfwM2+^ z2Cb@6n|Y6HNjZU5a(KUW0+kOev(2l_%goCqE-S@l$Ei_JLw)pCHa*HTHMKy+m*{kb z*b4e_jWW`Zeq%vLioNw?pzZJ>$*{vIc1PvpW8~N*S3X9Ty%N-pp(`Jt$R8;+shhN$ zi?vlq`6c>g_`_)HzNI-Tl>EGSicHZmzZ;HhjZ_@P8mc%dBh4DFI69*gBTHjw#e|hG z>6kI%(+uGg7{x*AzBojqDduQWpQ%DJ{Q;UZFiJHwtkdgP>2H662|U9jW#nSp!+!yT C6~GAq literal 0 HcmV?d00001 diff --git a/APL2.1/TP04/Periode/MyDate.java b/APL2.1/TP04/Periode/MyDate.java new file mode 100644 index 0000000..b3bdb04 --- /dev/null +++ b/APL2.1/TP04/Periode/MyDate.java @@ -0,0 +1,37 @@ +public class MyDate { + private int year; + private int month; + private int day; + + private int[] monthDurations = new int[] {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; + + public String toString() { + return String.format("%04d-%02d-%02d", year, month, day); + } + + public MyDate tomorrow() { + MyDate newDate = new MyDate(this.year, this.month, this.day+1); + + if (newDate.day > monthDurations[newDate.month-1]) { + newDate.day = 1; + newDate.month += 1; + } + + if (newDate.month > 12) { + newDate.month = 1; + newDate.year += 1; + } + + return newDate; + } + + public boolean isEqual(MyDate date) { + return (this.year == date.year && this.month == date.month && this.day == date.day); + } + + public MyDate(int y, int m, int d) { + this.year = y; + this.month = m; + this.day = d; + } +} \ No newline at end of file diff --git a/APL2.1/TP04/Periode/MyPeriod.class b/APL2.1/TP04/Periode/MyPeriod.class new file mode 100644 index 0000000000000000000000000000000000000000..a772e5a08624c349b7eea27c0d461c2ea8711c2b GIT binary patch literal 1177 zcmaKs+int36o&r|lmR+DK@Yaoo@_19ljlP*UPx^u0S}?6QE%LZNjqgagTqjRPoiF% z^i~tCNiTc=-^7=&{&T26G$zcNz1HmguWzlrH$Q%zdv6;|5yNB*=aY=gBoN1J z0;8C7%|!+C3Kj&ShGyqa>rn#uk6T5tt9K7uiz4;Wwp8?TLR&9W}EI^-PE0X0;zPd)Y_1amOFcA zwiPT=JY8@nCdyXRu4tROr(0@0(QMtSuDUcT66hssLjVGU_btn5IJT^pG-uDMHU^?d z$B~Yj^r0I}uFQ;ACV7^_0ZXQ}SE!ZRzEcCgpNqp!mU=FyV@oTroZe6`3=u?_9BqTOT#GZJQfP>2rRT! zx>9tr2~7Qe9%gwD;=BL?A@}fb6yaD!A8kLq0>T^tvfqsns6rbte2^j-; literal 0 HcmV?d00001 diff --git a/APL2.1/TP04/Periode/MyPeriod.java b/APL2.1/TP04/Periode/MyPeriod.java new file mode 100644 index 0000000..34aab20 --- /dev/null +++ b/APL2.1/TP04/Periode/MyPeriod.java @@ -0,0 +1,31 @@ +public class MyPeriod { + + private int length; + + public String toString() { + return "Periode : " + length + " jour" + (length > 1 ? "s" : ""); + } + + public void addDay() { + this.length += 1; + } + + public MyPeriod(MyDate date1, MyDate date2) { + if (date1.isEqual(date2)) { + this.length = 0; + return; + } + + //Très dangereux et inefficace, ne faites pas ca svp. + while (!date1.isEqual(date2)) { + date1 = date1.tomorrow(); + length++; + } + } + + public MyPeriod(int length) { + this.length = length; + } + + +} \ No newline at end of file diff --git a/APL2.1/TP04/Periode/Periode.class b/APL2.1/TP04/Periode/Periode.class new file mode 100644 index 0000000000000000000000000000000000000000..fa08fd68e4fc339f08853dae9038c8972469cef3 GIT binary patch literal 575 zcmZWm%T5A85UhcPfpry-hc8g^fr~HnPF!rz-G|XYTtJ780J@fwc`Uc<(Srsax95EFh#5ocw6f6a?j1`%!s#rskBgL`K z;6FDl)45>q>e(8Da%tZShEUP8M7iH>h~BNy=uk!J8m7gN(C>8rT3`2P8dDCc%rbBvqp-_;{QN8F&=YOND{$W%HkB;clhIXHLad&>x&Q)l5hgJ|q zH%}8ew!02POwZ0PNk)?){u61)2PxB`w~6bstZWTw1nEEI@qo#3DoCe9;de#ieUMj zOM=}?Zg}DiA|+4L*+}a1a1?W=Y?7hTk(v-%erGTZ@4{{zs!8{|d%#MEk&4U_K@5{r zkL5{}@oK%?EY*7%#YG8@gLM}h*mO}xg_RcwLSrd=Hk!(@AvBk*zA|zmHKA^j<4A@2 zez8&8@BgzBcKH4xe+8kC`Eq7)UPgtZ;A%IofogE|1hTK6L614S%26;0OcP8bxTyV* yw)rKVlmq6xqVVv`DCK>@k?-P|Sp=+-p+)clE3p1J)Y%@aYv*{6aURzNG`;}$V@}op literal 0 HcmV?d00001 diff --git a/APL2.1/TP04/Progression/Compteur.java b/APL2.1/TP04/Progression/Compteur.java new file mode 100644 index 0000000..23a0d22 --- /dev/null +++ b/APL2.1/TP04/Progression/Compteur.java @@ -0,0 +1,16 @@ +public class Compteur { + // attribut + private int compte; + // méthode + public void plusUn() { + this.compte++; + } + // autre méthode + public String toString() { + return Integer.toBinaryString(this.compte); + } + + public Compteur() { + this.compte = 0; + } +} \ No newline at end of file diff --git a/APL2.1/TP04/Progression/Progression.class b/APL2.1/TP04/Progression/Progression.class new file mode 100644 index 0000000000000000000000000000000000000000..a872de3c810faed59929372628c15dbb5630201f GIT binary patch literal 576 zcmZWm%TB^j5IxfZg;E3seB%2N&_tFld~8fy;UhswjH`k-zdRWI}#Vn-@+=D_!wzUX$P=dLQc1rtd^eA{z6fe3vIlSmqvvM`Mq z3$vIrFmGW2i-hDKGE4nV->zn*p(M@NB(6H(7;egi` zwzJOj1Mk}cAy+K*8zW?U>8;%L>b5KVO(l-^ZBau ow4UBLD}vc^M3G^f13xF@5>LqRO$z!uOamH?zHyl_*rN`80eAg(S^xk5 literal 0 HcmV?d00001 diff --git a/APL2.1/TP04/Progression/Progression.java b/APL2.1/TP04/Progression/Progression.java new file mode 100644 index 0000000..2698eef --- /dev/null +++ b/APL2.1/TP04/Progression/Progression.java @@ -0,0 +1,10 @@ +public class Progression { + public static void main(String[] args) { + Compteur cp = new Compteur(); + + for (int i = 0; i < 9; i++) { + cp.plusUn(); + if (i > 3) System.out.println(cp.toString()); + } + } +} \ No newline at end of file