From e7d8a77da8b1cbff0e176a3bc2570f862d54a86b Mon Sep 17 00:00:00 2001 From: Baptiste Royer <baptiste.royer.etu@univ-lille.fr> Date: Tue, 21 May 2024 11:16:36 +0200 Subject: [PATCH] housekeeping --- bin/tp09/DicoJava.class | Bin 0 -> 1546 bytes lib/tp04-res.jar | Bin 0 -> 9883 bytes lib/tp07-res.jar | Bin 0 -> 4246 bytes lib/tp09-res.jar | Bin 0 -> 5712 bytes res/tp09/DicoJava.txt | 53 ++++++++++ res/tp09/directory.txt | 5 + res/tp09/testScan.csv | 4 + src/tp03/Card.java | 44 +++++++++ src/tp03/Color.java | 5 + src/tp03/Rank.java | 15 +++ src/tp03/UseCard.java | 13 +++ src/tp03/UseLocalDate.java | 19 ++++ src/tp04/NumeroAutomatique.java | 9 ++ src/tp04/Person.java | 44 +++++++++ src/tp04/Student.java | 90 +++++++++++++++++ src/tp04/StudentAbs.java | 38 +++++++ src/tp04/UsePendingCaseQueue.java | 29 ++++++ src/tp04/UsePerson.java | 28 ++++++ src/tp04/UseStudent.java | 20 ++++ src/tp04/UseYearGroup.java | 20 ++++ src/tp04/YearGroup.java | 40 ++++++++ src/tp05/Book.java | 95 ++++++++++++++++++ src/tp05/ComicBook.java | 18 ++++ src/tp05/Library.java | 89 +++++++++++++++++ src/tp05/LibraryTest.java | 105 ++++++++++++++++++++ src/tp05/ShopTest.java | 158 ++++++++++++++++++++++++++++++ src/tp05/Test.java | 9 ++ src/tp05/UseLibrary.java | 50 ++++++++++ src/tp09/DicoJava.java | 67 +++++++++++++ src/tp09/HierarchyCreation.java | 62 ++++++++++++ tp06 | 1 - 31 files changed, 1129 insertions(+), 1 deletion(-) create mode 100644 bin/tp09/DicoJava.class create mode 100755 lib/tp04-res.jar create mode 100644 lib/tp07-res.jar create mode 100644 lib/tp09-res.jar create mode 100755 res/tp09/DicoJava.txt create mode 100755 res/tp09/directory.txt create mode 100755 res/tp09/testScan.csv create mode 100644 src/tp03/Card.java create mode 100644 src/tp03/Color.java create mode 100644 src/tp03/Rank.java create mode 100644 src/tp03/UseCard.java create mode 100644 src/tp03/UseLocalDate.java create mode 100644 src/tp04/NumeroAutomatique.java create mode 100644 src/tp04/Person.java create mode 100644 src/tp04/Student.java create mode 100644 src/tp04/StudentAbs.java create mode 100755 src/tp04/UsePendingCaseQueue.java create mode 100644 src/tp04/UsePerson.java create mode 100644 src/tp04/UseStudent.java create mode 100644 src/tp04/UseYearGroup.java create mode 100644 src/tp04/YearGroup.java create mode 100644 src/tp05/Book.java create mode 100644 src/tp05/ComicBook.java create mode 100644 src/tp05/Library.java create mode 100644 src/tp05/LibraryTest.java create mode 100644 src/tp05/ShopTest.java create mode 100644 src/tp05/Test.java create mode 100644 src/tp05/UseLibrary.java create mode 100644 src/tp09/DicoJava.java create mode 100755 src/tp09/HierarchyCreation.java delete mode 160000 tp06 diff --git a/bin/tp09/DicoJava.class b/bin/tp09/DicoJava.class new file mode 100644 index 0000000000000000000000000000000000000000..7598ffddb1b78e518d77c4caad951af791445461 GIT binary patch literal 1546 zcmX^0Z`VEs1_oP(2rdRD24;2!79Ivx1~x_pfvm)`ME#t^ymWp4q^#8B5=I6#o6Nk- z5<5l)W)00SE(Q(;PId+^9tLg(9u(!lB}JKe>5L3)IjMQ+B^hAlo*?CXJPiB{0*nl7 z$r*`7jwOr?EE=Ag&g=|Aj0{3x+cNX@-7<4hgHjVyQj0hkL>L)Fi&BgAO9~7u^<6TP z^Su(w67@<dO1KyV8N@*D6lY`*)$jr91-letwY6p#JA)*eq2WcDB_Knk85wxeGILV% z5_3}_W=SxJu`|dqGKhiA$;{VxDosmEElN#+xPyy9mO%kznIa>DFx0Zle0_+dH7Fot z8I*Y#R2Wnl890hk6H|OL^HLcZL^L!p9md6=&Y;20pvl9a#h}f|z>DHDMh4;Z)Dq9U zl+5JRki?|YoWzpM{5%{!1P7=t4}%_qJ|hEXacNR<2_)3TG(0`A*et}rz+lM3V8md| z$RM7Zn4RjJpO>6i5}sL-;hdjWT#}eqQq0Jp2K66GU}E!z1cNCLgBgQ3BLizWC}2T> zWWmE=2}(Jv$vOGOsay;a3>NGRHjE6yuyFPCcdbZHEdcq7i@}<~j)%b>q@KT^C^N4l zxFj(-JESNvIhB!t#W_DEm63rT6q0_Wxk;%-A&E&jsf-M~U{$_}1yDXqZenI0BZHVm zG^Qg#iNKAKK^Th^BLi1(erZv1Dk!xvGVsFF7RaTH3<6I1`6b0AMTrHzsU;ctDaHJ3 z4BlJ}J`BF>41S<6^k-yH0V#!KkIcNX{OnYHNZNx0t6O4nNq$i!Bf|{j0EH@q80wLj zmy(lOtm2cOpIusDjp=?Q5fqIfl?AC-lp}i+l3}fplL6ES=fs?x;LMU#YYv7$Mg}HE zE=C3(&%C_UBIlgM;^Nd|c7_l}22~8dVRJG&Ll`529Db#Y3~UhpF(@*qGcYlL05bz4 zsDxo)WN=_$V31{CWME`qU|`kS&cL{lfq{XM!I6Q1fekFk$-oK9C{U%o3`}4nWSDKF zwYD*^FJchZlHSI^E5JFQfwP5?aryt((rXwP7?{8&2r;lQFfi~iFfs5lh%oRmNHGX7 zI599Vuro0IVPIkuXW(RTW^jQTeVc)qft7)QA!;{+V5E@nb_P+O-3$_uLQ>lqWPEos z$VO^!XOQ>P-Nv9~#Ujaaj6p?`g;|ni2ZP!+1|2IF9Z8m53<eAg+ZaqBN|yh>tGkWC zTxT1D)p7<7AMI@nwj0473S<aju!cI&ih+-TfkB*si$RJ(gh3Wm$}lK1C^2X-s4$o^ zs4_S(s55vnXfpURXfXsb=rV*bXfuQ|=rBYw=z%?=&cO1YL79P-oxzozL6Dt6f}KH@ zoq>aaLG?ca7Xu?ZgDZ%zW?^7va0iEq2ZJXA0|N&GBZC(MBSQc~5Ca29Aww`jC_^}d FBmnPWZutNJ literal 0 HcmV?d00001 diff --git a/lib/tp04-res.jar b/lib/tp04-res.jar new file mode 100755 index 0000000000000000000000000000000000000000..4088fda2baee4ed5f221ddd3c9999890d7f2637f GIT binary patch literal 9883 zcmWIWW@h1HVBlb2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19Nv!5Y=$cW}EqVh1 z)zRmXHA6<q5ccBN`U^=bs1nvk4l4XwRau~+n_N<01gie<X$7@B5J43H(~2~*hTFxc zdTY@1;twcPy(`f4qGoY)?}92|gqyFR>4jFu#5$Xq6&hM8#fF%P1Kny=XX~Ts#qVWQ zXGf#yCDGYk2<@Qc0UpW2?Pb)0e;X^bPy}}caO*-Xgzq5ff{gSLtCNilVIO)Sj2^(K zb{e4QL@k8Tb)we6QEUthkk$~s)Q@Ug9b6A=q>xx2u0YX=TI8d<6V=X3C^}J#eEd59 zpy)&`^6~3bV~2$e$e*Z1K7O46$U4!Ad~}_tMSc}KbeIuebbxx5h>SfKrUg1Oi90e- z^&Lghhd)Q6>U)c%4}SrKs!x;y>a~&-v=#<>kf7?bMbd{qX`|{(Mbd{qsiErYMbd{q zp`q&Ailh&JGDFpO7fB!fM24!5l@lJGBqcFjkUr2b2=PfQ0Hy^xl1gk6t3c96N)lUu zq>q#&b^=KsXdHo&NrXWJ=h!PE3w=P<hdvTZd_c|MVPGf$g>6XzcnXEsfI5JrkCe3f z0!be!X;pw1;Z9Q0ss)lhQqpPyLLW(KwF9h=K>drFEmp&{K!@gtje^Ta`bbH0zmfDo z(j06I0lip5t$CICKv4i1dc&8zP#aS2a6O2jJ>32S4elY*crjcr`cNNk6HrG6mhv$$ zKu7h6ck(HOCiqYwZVOSp`wdMm{@_K`tHcj)uYwzX_=_LV*dHRO{4n%F$DwdL9Myn& zYzE+W0cxvv1DXK@TfLxBErbW|W7AI152$7c3!nxd*a@i>`S`to+G=x0GJ{YL3pD@= z(R31YJgW8unA-8X8&&&xRPB(lNPKA?HR%3f(@xL_sAd=mB7z@zI26A(P|ZjaL~g*M W4t27EOQRTu7>3s(3=Fft{s#c<TaNGm literal 0 HcmV?d00001 diff --git a/lib/tp07-res.jar b/lib/tp07-res.jar new file mode 100644 index 0000000000000000000000000000000000000000..6926c42ee68ba1e984e142fe33e8dd818aae5833 GIT binary patch literal 4246 zcmWIWW@Zs#VBp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79|>SQ<=7)n51D=9!L zZt(lh1xX(%QI~_HkCdpJf~1d>sM`b9hgMeL_u74!7H9=ZY!t9_f`SrK@q(g&l?{}$ Q6d4p50@)cD^f^I10JOk}6aWAK literal 0 HcmV?d00001 diff --git a/lib/tp09-res.jar b/lib/tp09-res.jar new file mode 100644 index 0000000000000000000000000000000000000000..11bab3bbfd189ba434befcd2bf9940689f047fc8 GIT binary patch literal 5712 zcmWIWW@h1HVBlb25Z9>+VL$?`3=9mVC7C(;ASEIU3>+K`96D7YJ~~o6e=svJY~^5J zkbx=j$V@FtEK1I(bS_FwEXmBz(@V}tEG}LedNx?bRpkHIGl$OTIV*5S8pNw9DoWdx zZI))@oRH!0DN)Sh4hK_~Oxo<bjem>M%nn8Bhef77&6+CiZ}}v_M(1M4(-)5ZQDKpC zLI0%Xu6+7>Mo*xOkL9_+-(P?0-hZwB`>XW-m-qbV8G9Bia7gM1kujFvpIPL+z30xc zB}Yq->xhc7NZbnl%3fu&UVQV%n@>aYEO^d7PP<sL&gjI&;$oi0lR<6m3d$=Ma-QYM z)!cj{U8^-U@9yR4pXVsf(UPpH^V{xYxL%Xl@7xy2UBUlW_Z!Nbc^hUV)3t1yvX}L= z$TNMN8cxBl+4Q;l)+(I2@Nm<apg-5%h%H($*>N@V^|LmucN;r6cKdqVm5Mu@=rv*e z>}|=rIrUaqoDx`b<4)I8FV;;KeZpLE^_l6Hq_-XBmhyWf;_N-mx_nL0%;<A$&g<j% z^lGs#m)uphT3sv6?(kZHD#6f#Z%<8Q+uDj>BnQa7_{lXt_U6`k;fDLaI=ygI@v!92 z>QMBPytQXd^seAdE<0;}a`Jk{EO>kIbZXog1D<!9+oOb%we&6-MXQR+xtqisN@csM zSsBxIZiW9AtrsRNM$4uK6t*t(^xzEKXl}CSW!RbxZdTDpTaJ5kebD6%X38mY6gBsV zS-5ETwCyH)bPt3%%jnu2wqH5FeM(#A8G)qY^sKqkqRY$T7I!}~xwEp;b5%vVSRd!l zrmkw0-RCrq?A+x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TIwJVKpN_dOd<>-IGgGSEy^%0I2!H&-ncCXRS^i2LRpY2blkc?RR%&=HIgn! z1y8Kbr6@W<`G;7Y=TUTmB9K^}KT&joqLWyi%B+acDF#<q#Om}#(Fw|j#Of?Z(Fw|# z#Ohp#q7#1-M2*kWC^|v87q^|L>E|m<C%D+htqavYX*OuMf}0hjqykqIo%rJtRMH^Q zY(5*JfkLc1C&TrCvNx#IC06HN6rK3vAGJ7m&IWC*;LF6I$^hXtE_SFEXafhgBT@Ak zA?d>(38?y_ko4ith^YFSko4h?I#hkDko4h?1XO*Oko4h?0#tp!ko4itfT;SEI1urG zKl`ET^Fq>xKl7m`l_HQnQ0s^Iq%swz1=;{3HmU4I(nm^^KSk1qKgv<P#>>gTPy%XA z5breum=<UQj##fnAn79|7c?O0BPB>yAnC&&B&ez60+K#ba={NIeWc_91uke5loS|{ zk_$YL^pTPa3Xt^S&jqLj`wXx?NP`l0oP%0*h!S%TTo0mwiCZtIiHXqrf{TFx+LpwZ zI8iO+<%Vm5H$ZV)h^p5TO)vgL18R~Y9Gl7wtMx!N7-|ER6&#KR3<eAfxfmE`a)WdM E096$P%>V!Z literal 0 HcmV?d00001 diff --git a/res/tp09/DicoJava.txt b/res/tp09/DicoJava.txt new file mode 100755 index 0000000..fa57b1e --- /dev/null +++ b/res/tp09/DicoJava.txt @@ -0,0 +1,53 @@ +abstract Mot-clé Déclaration d'une méthode ou d'une classe abstraite. +assert Mot-clé Assertion +break Mot-clé Interrompre une boucle ou un choix multiple. +case Mot-clé Cas dans un choix multiple. +catch Mot-clé Capture d'un type d'exception. +class Mot-clé Déclaration d'une classe. +continue Mot-clé Continuer une boucle en allant à l'itération suivante. +default Mot-clé Cas par défaut dans un choix multiple. +do Mot-clé Boucle itérative. +else Mot-clé Exécution conditionnelle. +enum Mot-clé Déclaration d'une énumération. +extends Mot-clé Héritage : déclaration de la classe mère, ou pour une interface de toutes les interfaces mères. +final Mot-clé Déclarer un membre comme final. +finally Mot-clé Code exécuté quoi qu'il se passe dans un bloc de capture d'exception. +for Mot-clé Boucle itérative. +if Mot-clé Exécution conditionnelle. +implements Mot-clé Déclaration des interfaces implémentées par une classe. +import Mot-clé Déclaration des packages utilisés par une classe. +instanceof Mot-clé Tester si un objet est de la classe indiquée (voir Transtypage). +interface Mot-clé Déclaration d'une interface. +native Mot-clé Déclaration d'une méthode native. +new Mot-clé Allocation d'une instance de classe. +package Mot-clé Déclaration du package de la classe. +private Mot-clé Déclaration d'un membre privé de la classe. +protected Mot-clé Déclaration d'un membre protégé de la classe. +public Mot-clé Déclaration d'un membre public de la classe. +return Mot-clé Retourner une valeur depuis une méthode. +static Mot-clé Déclaration d'un membre statique de la classe. +strictfp Mot-clé Déclaration d'une méthode ou classe où les opérations en virgule flottante doivent être évaluées strictement de gauche à droite selon la spécification Java. +super Mot-clé Référence à l'instance de la classe mère. +switch Mot-clé Début d'un choix multiple. +synchronized Mot-clé Voir Processus légers et synchronisation. +this Mot-clé Référence à l'instance de la classe englobante. +throw Mot-clé Lever une exception. +throws Mot-clé Déclaration des exceptions levées par une méthode. +transient Mot-clé Déclaration d'un attribut à exclure de la sérialisation. +try Mot-clé Capture d'un type d'exception. +void Mot-clé Déclaration d'une méthode ne retournant aucune valeur. +volatile Mot-clé Déclaration d'un attribut volatile, c'est à dire dont la valeur ne doit pas être mise en cache car elle est accédée par différents threads. +while Mot-clé Boucle itérative. +const Réservé Inutilisé actuellement. +goto Réservé Inutilisé actuellement. +boolean Type de données Valeur booléenne (vrai ou faux). +byte Type de données Entier signé de -128 à +127. +char Type de données Caractères Unicode (UTF-16, donc sur 16 bits). +double Type de données Nombre à virgule flottante, double précision. +float Type de données Nombre à virgule flottante, simple précision. +int Type de données Entier signé de -2 147 483 648 à +2 147 483 647. +long Type de données Entier signé de -9 223 372 036 854 775 808 à +9 223 372 036 854 775 807. +short Type de données Entier signé de -32 768 à +32 767. +false Valeur littérale Valeur booléenne fausse. +null Valeur littérale Référence nulle. +true Valeur littérale Valeur booléenne vraie. diff --git a/res/tp09/directory.txt b/res/tp09/directory.txt new file mode 100755 index 0000000..b782270 --- /dev/null +++ b/res/tp09/directory.txt @@ -0,0 +1,5 @@ +Alice 2015 +Bruno 1942 +Clément 2019 +Dorothée 1980 +Élise 1954 diff --git a/res/tp09/testScan.csv b/res/tp09/testScan.csv new file mode 100755 index 0000000..003bf1d --- /dev/null +++ b/res/tp09/testScan.csv @@ -0,0 +1,4 @@ +1;3;true;false;true +1;2;false;true +2;1;42 +42;2;poo;coo diff --git a/src/tp03/Card.java b/src/tp03/Card.java new file mode 100644 index 0000000..b732c43 --- /dev/null +++ b/src/tp03/Card.java @@ -0,0 +1,44 @@ +package tp03; + +class Card { + private Color color; + private Rank rank; + + public Card(Color color, Rank rank) { + this.color = color; + this.rank = rank; + } + + public Card(String color, String rank) { + this.color = Color.valueOf(color); + this.rank = Rank.valueOf(rank); + } + + public Color getColor() { + return this.color; + } + + public Rank getRank() { + return this.rank; + } + + public int compareRank(Card card) { + return this.rank.getValeur() - card.rank.getValeur(); + } + + public int compareColor(Card card) { + return this.color.compareTo(card.getColor()); + } + + public boolean isBefore(Card card) { + return this.rank.getValeur() - card.rank.getValeur() < 0; + } + + public boolean equals(Card card) { + return this.compareColor(card) == 0 && this.compareRank(card) == 0; + } + + public String toString() { + return this.rank.toString() + " of " + this.color.toString(); + } +} \ No newline at end of file diff --git a/src/tp03/Color.java b/src/tp03/Color.java new file mode 100644 index 0000000..47cb948 --- /dev/null +++ b/src/tp03/Color.java @@ -0,0 +1,5 @@ +package tp03; + +public enum Color { + CLUB, DIAMOND, HEART, SPADE; +} \ No newline at end of file diff --git a/src/tp03/Rank.java b/src/tp03/Rank.java new file mode 100644 index 0000000..4351125 --- /dev/null +++ b/src/tp03/Rank.java @@ -0,0 +1,15 @@ +package tp03; + +public enum Rank { + SEVEN(7), EIGHT(8), NINE(9), TEN(10), JACK(11), QUEEN(12), KING(13), ACE(14); + + private final int valeur; + + private Rank(int valeur) { + this.valeur = valeur; + } + + public int getValeur() { + return this.valeur; + } +} \ No newline at end of file diff --git a/src/tp03/UseCard.java b/src/tp03/UseCard.java new file mode 100644 index 0000000..f2876c0 --- /dev/null +++ b/src/tp03/UseCard.java @@ -0,0 +1,13 @@ +package tp03; + +class UseCard { + public static void main(String[] args) { + Card carte1 = new Card(Color.SPADE, Rank.SEVEN); + Card carte2 = new Card("HEART", "KING"); + System.out.println(carte1.getColor()); + System.out.println(carte2.getRank()); + System.out.println(carte1.isBefore(carte2)); + System.out.println(carte1.equals(carte2)); + System.out.println(carte1.toString() + "\n" + carte2.toString()); + } +} \ No newline at end of file diff --git a/src/tp03/UseLocalDate.java b/src/tp03/UseLocalDate.java new file mode 100644 index 0000000..e418ac3 --- /dev/null +++ b/src/tp03/UseLocalDate.java @@ -0,0 +1,19 @@ +package tp03; +import java.time.LocalDate; +import java.util.Scanner; + +class UseLocalDate { + private Scanner scan = new Scanner(System.in); + + public static String dateOfTheDay() { + return "Today's date is " + LocalDate.now() + "."; + } + + public static void main(String[] args) { + System.out.println(dateOfTheDay()); + } + + public static LocalDate inputDate() { + return null; + } +} \ No newline at end of file diff --git a/src/tp04/NumeroAutomatique.java b/src/tp04/NumeroAutomatique.java new file mode 100644 index 0000000..4427b3c --- /dev/null +++ b/src/tp04/NumeroAutomatique.java @@ -0,0 +1,9 @@ +package tp04; + +public class NumeroAutomatique { + private static int numero = 0; + + public static int getNumber() { + return ++numero; + } +} \ No newline at end of file diff --git a/src/tp04/Person.java b/src/tp04/Person.java new file mode 100644 index 0000000..b6e4a6e --- /dev/null +++ b/src/tp04/Person.java @@ -0,0 +1,44 @@ +package tp04; + +import tp04.NumeroAutomatique; + +public class Person { + private int ID; + private String forename; + private String name; + + public Person(String forename, String name) { + this.forename = forename; + this.name = name; + NumeroAutomatique temp = new NumeroAutomatique(); + this.ID = temp.getNumber(); + } + + public int getID() { + return this.ID; + } + + public String getForename() { + return this.forename; + } + + public String getName() { + return this.name; + } + + public void setName(String name) { + this.name = name; + } + + public void setForename(String forename) { + this.forename = forename; + } + + public String toString() { + return ID + " : " + forename + " " + name; + } + + public boolean equals(Person other) { + return this.ID == other.ID; + } +} \ No newline at end of file diff --git a/src/tp04/Student.java b/src/tp04/Student.java new file mode 100644 index 0000000..84b1305 --- /dev/null +++ b/src/tp04/Student.java @@ -0,0 +1,90 @@ +package tp04; + +public class Student{ + private Person person; + private double[] grades; + + public Student(Person pers, double[] grades) { + this.person = pers; + this.grades = grades; + } + + public Student(String forename, String name, double[] grades) { + this.person = new Person(forename, name); + this.grades = grades; + } + + public Student(String forename, String name) { + this.person = new Person(forename, name); + this.grades = new double[0]; + } + + public String getForename() { + return this.person.getForename(); + } + + public String getName() { + return this.person.getName(); + } + + public int getID() { + return this.person.getID(); + } + + public double[] getGrades() { + return this.grades; + } + + public String getStringGrades() { + String result = "["; + for (int i = 0; i<this.grades.length; i++) { + result += this.grades[i] + ";"; + } + result = result.substring(0, result.length() - 1); + return result + "]"; + } + + public void setForename(String forename) { + this.person.setForename(forename); + } + + public void setName(String name) { + this.person.setName(name); + } + + public void setGrades(double[] grades) { + this.grades = grades; + } + + public String toString() { + return "Student [" + this.person.getID() + " : " + this.person.getForename() + " " + this.person.getName() + " = " + getStringGrades() + "; avg = " + getAverage() + "]"; + } + + public boolean equals(Student other) { + return (this.person == other.person && this.grades == other.grades); + } + + public double getAverage() { + if (grades.length == 0) { + return 0; + } else { + int somme = 0; + for (int i = 0; i<grades.length; i++) { + somme += grades[i]; + } + return somme/grades.length; + } + } + + public void addGrade(double grade) { + double[] temp = this.grades; + this.grades = new double[temp.length + 1]; + for (int i = 0; i<grades.length; i++) { + if (i<temp.length) { + this.grades[i] = temp[i]; + } else { + this.grades[i] = grade; + } + } + } +} \ No newline at end of file diff --git a/src/tp04/StudentAbs.java b/src/tp04/StudentAbs.java new file mode 100644 index 0000000..09f736b --- /dev/null +++ b/src/tp04/StudentAbs.java @@ -0,0 +1,38 @@ +package tp04; + +public class StudentAbs { + private Student stud; + private int nbAbsence = 0; + + public StudentAbs(Student stud) {this.stud = stud;} + public StudentAbs(String forename, String name, double[] grades) {this.stud = new Student(forename, name, grades);} + public StudentAbs(String forename, String name) {this.stud = new Student(forename, name);} + + public Student getStud() { + return this.stud; + } + + public int getNbAbsences() { + return this.nbAbsence; + } + + public void increaseAbs() { + this.nbAbsence++; + } + + public String toString() { + return this.stud.toString() + ", nbAbs = " + nbAbsence; + } + + public boolean equals(StudentAbs other) { + return (this.stud.equals(other.stud) && this.nbAbsence == other.nbAbsence); + } + + public boolean warning(int thresholdAbs, double thresholdAvg) { + return (this.nbAbsence >= thresholdAbs || this.stud.getAverage() <= thresholdAvg); + } + + public boolean validation(int thresholdAbs, double thresholdAvg) { + return (this.nbAbsence <= thresholdAbs && this.stud.getAverage() >= thresholdAvg); + } +} \ No newline at end of file diff --git a/src/tp04/UsePendingCaseQueue.java b/src/tp04/UsePendingCaseQueue.java new file mode 100755 index 0000000..05bc892 --- /dev/null +++ b/src/tp04/UsePendingCaseQueue.java @@ -0,0 +1,29 @@ +package tp04; + +public class UsePendingCaseQueue { + public static void main(String[] args) { + PendingCase pc1 = new PendingCase("Alice", "AAA", 1234.56); + PendingCase pc2 = new PendingCase("Bruno", "BBB", 0.42); + PendingCase pc3 = new PendingCase("Chloé", "CCC", 745.99); + PendingCase pc4 = new PendingCase("Denis", "DDD", 125.0); + PendingCaseQueue.CAPACITY = 3; + PendingCaseQueue pcq = new PendingCaseQueue(); + System.out.println("Before anything: " + pcq); + System.out.println("Empty? " + pcq.isEmpty() + "\tFull? " + pcq.isFull()); + pcq.addOne(pc1); + pcq.addOne(pc2); + System.out.println("After addition of pc1 and pc2: " + pcq); + System.out.println("Empty? " + pcq.isEmpty() + "\tFull? " + pcq.isFull()); + pcq.addOne(pc3); + System.out.println("After addition of pc3: " + pcq); + System.out.println("Empty? " + pcq.isEmpty() + "\tFull? " + pcq.isFull()); + pcq.addOne(pc4); + System.out.println("After addition of pc4: \t" + pcq); + pcq.removeOne(); + System.out.println("After a removal: " + pcq); + pcq.addOne(pc1); + System.out.println("After addition of pc1: " + pcq); + pcq.clear(); + System.out.println("After clearing: " + pcq); + } +} diff --git a/src/tp04/UsePerson.java b/src/tp04/UsePerson.java new file mode 100644 index 0000000..aaf0940 --- /dev/null +++ b/src/tp04/UsePerson.java @@ -0,0 +1,28 @@ +package tp04; + +public class UsePerson { + public static void main(String[] args) { + Person alice = new Person("Alice", "A"); + Person bruno = new Person("Bruno", "B"); + Person autre = alice; + boolean testsOK = true; + // test des getters + if(!alice.getForename().equals("Alice") || !alice.getName().equals("A") || !bruno.getForename().equals("Bruno") || !bruno.getName().equals("B") || !autre.getForename().equals("Alice") || !autre.getName().equals("A")) { + System.out.println("Erreur de méthodes GET"); + testsOK = false; + } + // test des setters + alice.setForename("Anatole"); + bruno.setName("BB"); + if(!alice.getForename().equals("Anatole") || !alice.getName().equals("A") || !bruno.getForename().equals("Bruno") || !bruno.getName().equals("BB") || !autre.getForename().equals("Anatole") || !autre.getName().equals("A")) { + System.out.println("Erreur de méthodes SET"); + testsOK = false; + } + // test du equals + if(alice.equals(bruno) || !alice.equals(autre)) { + System.out.println("Erreur de méthode equals"); + testsOK = false; + } + if(testsOK) System.out.println("Tests de UsePerson réussis !"); + } +} diff --git a/src/tp04/UseStudent.java b/src/tp04/UseStudent.java new file mode 100644 index 0000000..c3e7fd8 --- /dev/null +++ b/src/tp04/UseStudent.java @@ -0,0 +1,20 @@ +package tp04; + +public class UseStudent { + public static void main(String[] args) { + double[] grades = new double[] {19.25, 15.2, 0.01}; + double[] grades2 = new double[] {5, 2849, 9}; + Person gens1 = new Person("AAAAAAAAAAAAAAAAAAA", "BBBBB"); + Student gars1 = new Student(gens1, grades); + Student gars2 = new Student("Jean-Marie", "Lepen", grades2); + Student gars3 = new Student("Gicé", "Védé"); + gars3.addGrade(5.49); + gars3.addGrade(5.49); + gars3.addGrade(5.49); + System.out.println(gars1.equals(gars2)); + System.out.println(gars2.equals(gars3)); + System.out.println(gars1.toString()); + System.out.println(gars2.toString()); + System.out.println(gars3.toString()); + } +} \ No newline at end of file diff --git a/src/tp04/UseYearGroup.java b/src/tp04/UseYearGroup.java new file mode 100644 index 0000000..6b6319d --- /dev/null +++ b/src/tp04/UseYearGroup.java @@ -0,0 +1,20 @@ +package tp04; + +public class UseYearGroup { + public static void main(String[] args) { + Student gars1 = new Student("Clara", "Oké", new double[] {19.25, 15.2, 17.3}); + Student gars2 = new Student("Will", "Kinson", new double[] {5, 13, 2}); + Student gars3 = new Student("Titouan", "Ladopté", new double[] {17.6, 14.3, 15.9}); + Student gars4 = new Student("Gicé", "Védé", new double[] {0, 0.1, 0.2}); + StudentAbs abs1 = new StudentAbs(gars1); + StudentAbs abs2 = new StudentAbs(gars2); + StudentAbs abs3 = new StudentAbs(gars3); + StudentAbs abs4 = new StudentAbs(gars4); + for (int i = 0; i < 10; i++) { + abs3.increaseAbs(); + abs4.increaseAbs(); + } + YearGroup BUT1 = new YearGroup(new StudentAbs[]{abs1, abs2, abs3, abs4}); + BUT1.validation(5, 14); + } +} \ No newline at end of file diff --git a/src/tp04/YearGroup.java b/src/tp04/YearGroup.java new file mode 100644 index 0000000..8efdbe4 --- /dev/null +++ b/src/tp04/YearGroup.java @@ -0,0 +1,40 @@ +package tp04; + +public class YearGroup { + private StudentAbs[] listeEtu; + + public YearGroup(StudentAbs[] liste) {this.listeEtu = liste;} + public YearGroup() {this.listeEtu = new StudentAbs[0];} + + public StudentAbs[] getListeEtu() { + return listeEtu; + } + + public String getStringListeEtu() { + String result = "["; + for (int i = 0; i<this.listeEtu.length; i++) { + result+=listeEtu[i].toString() + "\n"; + } + return result + "]"; + } + + public void setListeEtu(StudentAbs[] liste) { + this.listeEtu = liste; + } + + public void addGrade(double[] grades) { + for (int i = 0; i < this.listeEtu.length; i++) { + this.listeEtu[i].getStud().addGrade(grades[i]); + } + } + + public void validation(int thresholdAbs, int thresholdAvg) { + String lesGensQuiPassent = ""; + for (int i = 0; i < this.listeEtu.length; i++) { + if (this.listeEtu[i].validation(thresholdAbs, thresholdAvg)) { + lesGensQuiPassent+=listeEtu[i].toString() + "\n"; + } + } + System.out.println(lesGensQuiPassent.substring(0, lesGensQuiPassent.length() - 1)); + } +} \ No newline at end of file diff --git a/src/tp05/Book.java b/src/tp05/Book.java new file mode 100644 index 0000000..280ed8f --- /dev/null +++ b/src/tp05/Book.java @@ -0,0 +1,95 @@ +package tp05; + +import java.time.LocalDateTime; + +public class Book { + private String code; + private String title; + private String author; + private int publicationYear; + private int borrower = 0; + private LocalDateTime borrowingDate = null; + + public Book(String code, String title, String author, int publicationYear) { + this.code = code; + this.title = title; + this.author = author; + this.publicationYear = publicationYear; + } + + public String getCode() { + return this.code; + } + + public String getTitle() { + return this.title; + } + + public String getAuthor() { + return this.author; + } + + public int getPublicationYear() { + return this.publicationYear; + } + + public int getBorrower() { + return this.borrower; + } + + public LocalDateTime getBorrowingDate() { + return this.borrowingDate; + } + + public void setCode(String code) { + this.code = code; + } + + public void setTitle(String title) { + this.title = title; + } + + public void setAuthor(String author) { + this.author = author; + } + + public void setPublicationYear(int publicationYear) { + this.publicationYear = publicationYear; + } + + public boolean borrow(int borrower) { + if (this.borrower == 0) { + this.borrower = borrower; + this.borrowingDate = LocalDateTime.now(); + return true; + } else { + return false; + } + } + + public boolean giveBack() { + if (this.borrower != 0) { + this.borrower = 0; + this.borrowingDate = null; + return true; + } else { + return false; + } + } + + public LocalDateTime getGiveBackDate() { + return this.borrowingDate.plusDays(10); + } + + public boolean isAvailable() { + return this.borrower == 0; + } + + public String toString() { + String borrowed = ""; + if (this.borrowingDate != null) { + borrowed = " borrowed the : " + this.borrowingDate.toString(); + } + return "Book [" + this.getCode() + ":" + this.title + " -> " + this.author + ", " + this.publicationYear + "]" + borrowed; + } +} \ No newline at end of file diff --git a/src/tp05/ComicBook.java b/src/tp05/ComicBook.java new file mode 100644 index 0000000..7084160 --- /dev/null +++ b/src/tp05/ComicBook.java @@ -0,0 +1,18 @@ +package tp05; + +public class ComicBook extends Book { + private String illustrator; + + public ComicBook(String code, String title, String author, String illustrator, int publicationYear) { + super(code, title, author, publicationYear); + this.illustrator = illustrator; + } + + public String toString() { + String borrowed = ""; + if (super.getBorrowingDate() != null) { + borrowed = " borrowed the : " + super.getBorrowingDate().toString(); + } + return "ComicBook [" + super.getCode() + ":" + super.getTitle() + " -> " + super.getAuthor() + ", " + super.getPublicationYear() + ", " + this.illustrator + "]" + borrowed; + } +} diff --git a/src/tp05/Library.java b/src/tp05/Library.java new file mode 100644 index 0000000..58d5597 --- /dev/null +++ b/src/tp05/Library.java @@ -0,0 +1,89 @@ +package tp05; + +public class Library { + private Book[] catalog = new Book[0]; + + public Book getBook(String code) { + int i = 0; + while (i<this.catalog.length && this.catalog[i].getCode() != code) { + i++; + } + return catalog[i]; + } + + public boolean addBook(Book book) { + Book[] temp = catalog; + this.catalog = new Book[temp.length+1]; + for (int i = 0; i < temp.length; i++) { + this.catalog[i] = temp[i]; + } + this.catalog[temp.length] = book; + return true; + } + + public boolean removeBook(String aCode) { + Book remove = getBook(aCode); + int indice = getIndice(remove); + Book[] temp = this.catalog; + this.catalog = new Book[temp.length-1]; + int index = 0; + for (int i = 0; i<this.catalog.length; i++) { + if(i != indice) { + this.catalog[index] = temp[i]; + index++; + } + } + return true; + } + + public boolean removeBook(Book b) { + int indice = getIndice(b); + Book[] temp = this.catalog; + this.catalog = new Book[temp.length-1]; + int index = 0; + for (int i = 0; i<this.catalog.length; i++) { + if(i != indice) { + this.catalog[index] = temp[i]; + index++; + } + } + return true; + } + + public int getIndice(Book book) { + int i = 0; + while (i<this.catalog.length && this.catalog[i] != book) { + i++; + } + return i; + } + + public String borrowings() { + String result = ""; + for (int i = 0; i<this.catalog.length;i++) { + if (this.catalog[i].getBorrower() != 0) { + result += "(" + this.catalog[i].getCode() + ")--" + this.catalog[i].getBorrower() + " "; + } + } + return result; + } + + public boolean borrow(String code, int borrower) { + Book book = getBook(code); + return (book.borrow(borrower)); + } + + public boolean giveBack(String code) { + Book book = getBook(code); + return book.giveBack(); + } + + public String toString() { + String result = "["; + for (int i = 0; i<this.catalog.length; i++) { + result += this.catalog[i].toString() + "\n"; + } + return result.substring(0, result.length()-1) + "]"; + } + +} \ No newline at end of file diff --git a/src/tp05/LibraryTest.java b/src/tp05/LibraryTest.java new file mode 100644 index 0000000..a754214 --- /dev/null +++ b/src/tp05/LibraryTest.java @@ -0,0 +1,105 @@ +package tpOO.tp05; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertTrue; + +import java.time.LocalDate; + +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.BeforeEach; + +public class LibraryTest { + private int p1, p2; + private Book b1, b2, b3; + private Library myLib; + private ComicBook c1, c2; + + @BeforeEach + public void initialization() { + // borrowers + p1 = 42; + p2 = 404; + // books + b1 = new Book("H2G2", "The Hitchhiker's Guide to the Galaxy", "D. Adams", 1979); + b2 = new Book("FLTL", "Flatland", "E.Abbott Abbott", 1884); + b3 = new Book("REU", "The Restaurant at the End of the Universe", "D. Adams", 1980); + c1 = new ComicBook("LeuG", "Léonard est un Génie", "Bob de Groot", 1977, "Turk"); + c2 = new ComicBook("GVV", "Génie, Vidi, Vici !", "Turk", 2020, "Zidrou"); + // library + myLib = new Library(); + } + + @Test + public void scenario1() { + myLib.addBook(b1); myLib.addBook(b2); myLib.addBook(b3); + assertEquals(b1, myLib.getBook("H2G2")); + assertEquals(b2, myLib.getBook("FLTL")); + assertEquals(b3, myLib.getBook("REU")); + assertNull(myLib.getBook("ERR")); + assertEquals(3, myLib.stockSize()); + assertEquals("[Book [H2G2:The Hitchhiker's Guide to the Galaxy->D. Adams,1979], Book [FLTL:Flatland->E.Abbott Abbott,1884], Book [REU:The Restaurant at the End of the Universe->D. Adams,1980]]", myLib.toString()); + } + + @Test + void scenario2() { + myLib.addBook(b1); myLib.addBook(b2); myLib.addBook(b3); + assertEquals("", myLib.borrowings()); + assertEquals(0, myLib.borrowedBookNumber()); + // p1 borrows b1 successfully + assertTrue(myLib.borrow(b1.getCode(), p1)); + assertEquals(1, myLib.borrowedBookNumber()); + // p2 borrows b1 failed + assertFalse(myLib.borrow(b1.getCode(), p2)); + assertEquals(1, myLib.borrowedBookNumber()); + // p2 borrows b3 successfully + assertTrue(myLib.borrow(b3.getCode(), p2)); + assertEquals(2, myLib.borrowedBookNumber()); + // p1 borrows b2 successfully + assertTrue(myLib.borrow(b2.getCode(), p1)); + assertEquals(3, myLib.borrowedBookNumber()); + } + + @Test + void scenario3() { + myLib.addBook(b1); myLib.addBook(c1); + assertEquals(2, myLib.stockSize()); + assertEquals(0, myLib.borrowedBookNumber()); + assertEquals("[Book [H2G2:The Hitchhiker's Guide to the Galaxy->D. Adams,1979], ComicBook[LeuG:Léonard est un Génie->Bob de Groot,1977,Turk]]", myLib.toString()); + // p1 borrows b1 successfully + assertTrue(myLib.borrow(b1.getCode(), p1)); + assertEquals(1, myLib.borrowedBookNumber()); + assertEquals("(H2G2)--42", myLib.borrowings()); + // p1 borrows c1 successfully + assertTrue(myLib.borrow(c1.getCode(), p1)); + assertEquals(2, myLib.borrowedBookNumber()); + assertEquals("(H2G2)--42(LeuG)--42", myLib.borrowings()); + } + + @Test + void scenario4() { + myLib.addBook(b1); myLib.addBook(c1); myLib.addBook(c2); + assertEquals(3, myLib.stockSize()); + assertEquals(0, myLib.borrowedBookNumber()); + assertEquals("[Book [H2G2:The Hitchhiker's Guide to the Galaxy->D. Adams,1979], ComicBook[LeuG:Léonard est un Génie->Bob de Groot,1977,Turk], ComicBook[GVV:Génie, Vidi, Vici !->Turk,2020,Zidrou]]", myLib.toString()); + // p1 borrows b1 successfully + assertTrue(b1.borrowAgain(p1)); + assertEquals(15, b1.getDurationMax()); + assertEquals(LocalDate.now().plusDays(b1.getDurationMax()), b1.getGiveBackDate()); + assertEquals(1, myLib.borrowedBookNumber()); + assertEquals("(H2G2)--42", myLib.borrowings()); + // p1 borrows c1 successfully + assertTrue(c1.borrowAgain(p1)); + assertEquals(15, c1.getDurationMax()); + assertEquals(LocalDate.now().plusDays(c1.getDurationMax()), c1.getGiveBackDate()); + assertEquals(2, myLib.borrowedBookNumber()); + assertEquals("(H2G2)--42(LeuG)--42", myLib.borrowings()); + // p1 borrows c2 successfully + assertTrue(c2.borrowAgain(p1)); + assertEquals(5, c2.getDurationMax()); + assertEquals(LocalDate.now().plusDays(c2.getDurationMax()), c2.getGiveBackDate()); + assertEquals(3, myLib.borrowedBookNumber()); + assertEquals("(H2G2)--42(LeuG)--42(GVV)--42", myLib.borrowings()); + } +} diff --git a/src/tp05/ShopTest.java b/src/tp05/ShopTest.java new file mode 100644 index 0000000..dccaf25 --- /dev/null +++ b/src/tp05/ShopTest.java @@ -0,0 +1,158 @@ +package tpOO.tp05; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +import java.time.LocalDate; +import java.util.ArrayList; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +public class ShopTest { + private String ref1, ref2, ref3, ref4; + private String label1, label2, label3, label4; + private double p5, p10, p15, p20; + private Article a1, a2, a3, a4, a5; + private ArrayList<Article> arts; + public Shop mag; + + @BeforeEach + public void initialization() { + // articles' references + ref1 = "refA"; + ref2 = "refB"; + ref3 = "refC"; + ref4 = "refD"; + // articles' labels + label1 = "a"; + label2 = "b"; + label3 = "c"; + label4 = "d"; + // articles' prices + p5 = 5.0; + p10 = 10.0; + p15 = 15.0; + p20 = 20.0; + // articles + a1 = new Article(ref1, label1, p10); + a2 = new Article(ref2, label2, p15); + a3 = new PerishableArticle(ref2, label2, p15); + a4 = new PerishableArticle(ref3, label3, p20, LocalDate.now().plusDays(5)); + a5 = new PerishableArticle(ref4, label4, p5, LocalDate.now().minusDays(1)); + arts = new ArrayList<Article>(); + arts.add(a1); + arts.add(a2); + // shop + mag = new Shop(); + } + + @Test + public void toStringArticleTest() { + assertEquals("Article [refA:a=10.0€/12.0€]", a1.toString()); + assertEquals("Article [refB:b=15.0€/18.0€]", a2.toString()); + } + + @Test + public void addArticleShopTest1() { + assertEquals(0, mag.getNbArticle()); + mag.addArticle(a1); + assertEquals(1, mag.getNbArticle()); + mag.addArticle(a2); + assertEquals(2, mag.getNbArticle()); + } + + @Test + public void addArticleShopTest2() { + assertEquals(0, mag.getNbArticle()); + mag.addArticle(arts); + assertEquals(2, mag.getNbArticle()); + } + + @Test + public void toStringPerishableArticleTest() { + assertEquals("PerishableArticle [refB:b=15.0€/18.0€-->"+LocalDate.now().plusDays(10)+"]", a3.toString()); + assertEquals("PerishableArticle [refC:c=20.0€/24.0€-->"+LocalDate.now().plusDays(5)+"]", a4.toString()); + assertEquals("PerishableArticle [refD:d=5.0€/6.0€-->"+LocalDate.now().minusDays(1)+"]", a5.toString()); + } + + @Test + public void addArticleShopTest3() { + assertEquals(0, mag.getNbArticle()); + assertEquals(0, mag.getNbPerishableArticle()); + mag.addArticle(a1); + assertEquals(1, mag.getNbArticle()); + assertEquals(0, mag.getNbPerishableArticle()); + mag.addArticle(a3); + assertEquals(2, mag.getNbArticle()); + assertEquals(1, mag.getNbPerishableArticle()); + } + + @Test + public void discountPerishableTest_none() { + // no perishable article + mag.addArticle(a1); + assertEquals(1, mag.getNbArticle()); + assertEquals(0, mag.getNbPerishableArticle()); + double oldPriceA1 = a1.getSalePrice(); + mag.discountPerishable(LocalDate.now().plusDays(10), 0.5); + assertEquals(oldPriceA1, a1.getSalePrice()); + } + @Test + public void discountPerishableTest_oneOverTwo() { + // one perishable article concerned + mag.addArticle(a1); + mag.addArticle(a3); + mag.addArticle(a4); + assertEquals(3, mag.getNbArticle()); + assertEquals(2, mag.getNbPerishableArticle()); + double oldPriceA1 = a1.getSalePrice(); + double oldPriceA3 = a3.getSalePrice(); + double oldPriceA4 = a4.getSalePrice(); + mag.discountPerishable(LocalDate.now().plusDays(8), 0.5); + assertEquals(oldPriceA1, a1.getSalePrice()); + assertEquals(oldPriceA3, a3.getSalePrice()); + assertEquals(oldPriceA4/2, a4.getSalePrice()); + } + @Test + public void discountPerishableTest_all() { + // all perishable article concerned + mag.addArticle(a1); + mag.addArticle(a3); + mag.addArticle(a4); + assertEquals(3, mag.getNbArticle()); + assertEquals(2, mag.getNbPerishableArticle()); + double oldPriceA1 = a1.getSalePrice(); + double oldPriceA3 = a3.getSalePrice(); + double oldPriceA4 = a4.getSalePrice(); + mag.discountPerishable(LocalDate.now().plusDays(15), 0.5); + assertEquals(oldPriceA1, a1.getSalePrice()); + assertEquals(oldPriceA3/2, a3.getSalePrice()); + assertEquals(oldPriceA4/2, a4.getSalePrice()); + } + + @Test + public void discountNotPerishableTest_none() { + // only perishable article + mag.addArticle(a3); + assertEquals(1, mag.getNbArticle()); + assertEquals(1, mag.getNbPerishableArticle()); + double oldPriceA3 = a3.getSalePrice(); + mag.discountNotPerishable(0.5); + assertEquals(oldPriceA3, a3.getSalePrice()); + } + + @Test + public void discountNotPerishableTest_some() { + // one perishable article and one not perishable article + mag.addArticle(a1); + mag.addArticle(a3); + assertEquals(2, mag.getNbArticle()); + assertEquals(1, mag.getNbPerishableArticle()); + double oldPriceA1 = a1.getSalePrice(); + double oldPriceA3 = a3.getSalePrice(); + mag.discountNotPerishable(0.5); + assertEquals(oldPriceA1/2, a1.getSalePrice()); + assertEquals(oldPriceA3, a3.getSalePrice()); + } + +} diff --git a/src/tp05/Test.java b/src/tp05/Test.java new file mode 100644 index 0000000..56f69a0 --- /dev/null +++ b/src/tp05/Test.java @@ -0,0 +1,9 @@ +package tp05; + +public class Test { + public static void main(String[] args) { + Object test = new Book("A", "A", "Jean", 200); + + System.out.println(test.getClass() == Book.class); + } +} \ No newline at end of file diff --git a/src/tp05/UseLibrary.java b/src/tp05/UseLibrary.java new file mode 100644 index 0000000..bd64250 --- /dev/null +++ b/src/tp05/UseLibrary.java @@ -0,0 +1,50 @@ +package tp05; + +public class UseLibrary { + public static void main(String[] args) { + Library bookstore = new Library(); + Book book1 = new Book("LGDC", "La Guerre Des Clans", "Erin Hunter", 2003); + Book book2 = new Book("ERGN", "Eragon", "Christopher Paolini", 2002); + Book book3 = new Book("LMDO", "Les Métamprphoses D'Ovide", "Ovide", 100); + ComicBook book4 = new ComicBook("TAT", "Tintin Au Tibet", "Hergé", "Hergé", 1960); + int borrower1 = 42; + int borrower2 = 404; + + boolean add1 = bookstore.addBook(book1); + boolean add2 = bookstore.addBook(book2); + boolean add3 = bookstore.addBook(book3); + boolean add4 = bookstore.addBook(book4); + + Book search = bookstore.getBook("ERGN"); + + String script = bookstore.toString(); + + System.out.println(add1); + System.out.println(add2); + System.out.println(add3); + System.out.println(add4); + + newLine(); + + System.out.println(search.toString()); + + newLine(); + + System.out.println(script); + + newLine(); + + System.out.println(bookstore.borrow("ERGN", borrower1) + " --> " + bookstore.borrowings()); + System.out.println(bookstore.borrow("ERGN", borrower2) + " --> " + bookstore.borrowings()); + System.out.println(bookstore.borrow("LGDC", borrower2) + " --> " + bookstore.borrowings()); + System.out.println(bookstore.borrow("LMDO", borrower1) + " --> " + bookstore.borrowings()); + + newLine(); + + System.out.println(bookstore.toString()); + } + + public static void newLine() { + System.out.println(); + } +} \ No newline at end of file diff --git a/src/tp09/DicoJava.java b/src/tp09/DicoJava.java new file mode 100644 index 0000000..f4477c9 --- /dev/null +++ b/src/tp09/DicoJava.java @@ -0,0 +1,67 @@ +package tp09; + +import java.io.BufferedReader; +import java.io.FileReader; +import java.io.IOException; +import java.io.File; // Import the File class +import java.io.FileWriter; // Import the FileWriter class + +public class DicoJava { + + public static int getIndiceTabulation(String line) { + int i = 0; + while (i < line.length() && line.charAt(i) != '\t') { + i++; + } + return i; + } + + public static void main(String[] args) { + + try { + // Création d'un fileReader pour lire le fichier + FileReader fileReader = new FileReader("res/tp09/DicoJava.txt"); + + // Création d'un fichier + FileWriter myWriter = new FileWriter("MotsJava.txt"); + + // Création d'un bufferedReader qui utilise le fileReader + BufferedReader reader = new BufferedReader(fileReader); + + // une fonction à essayer pouvant générer une erreur + String line = reader.readLine(); + + while (line != null) { + // affichage de la ligne + line = line.substring(0, getIndiceTabulation(line)); + myWriter.write(line + "\n"); + // lecture de la prochaine ligne + line = reader.readLine(); + } + reader.close(); + myWriter.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } +} +/* +import java.io.File; // Import the File class +import java.io.IOException; // Import the IOException class to handle errors + +public class CreateFile { + public static void main(String[] args) { + try { + File myObj = new File("filename.txt"); + if (myObj.createNewFile()) { + System.out.println("File created: " + myObj.getName()); + } else { + System.out.println("File already exists."); + } + } catch (IOException e) { + System.out.println("An error occurred."); + e.printStackTrace(); + } + } +} +*/ diff --git a/src/tp09/HierarchyCreation.java b/src/tp09/HierarchyCreation.java new file mode 100755 index 0000000..3aaa161 --- /dev/null +++ b/src/tp09/HierarchyCreation.java @@ -0,0 +1,62 @@ +package util; + +import java.io.File; +import java.io.IOException; + +public class HierarchyCreation { + public static void hierarchyCreation(String path) throws IOException { + File f = new File(path); + if(!f.exists()) { + path = System.getProperty("user.home"); + } + path = path + File.separator + "hierarchy" + File.separator; + // directory dir1 and dir11 + String path_tmp = path + File.separator + "dir1" + File.separator + "dir11"; + File f_tmp = new File(path_tmp); + f_tmp.mkdirs(); + // directory dir2 + path_tmp = path + File.separator + "dir2"; + f_tmp = new File(path_tmp); + f_tmp.mkdir(); + // content of hierarchy + f = new File(path + "file1"); + f.createNewFile(); + f.setExecutable(true); + f = new File(path + "file2"); + f.createNewFile(); + f.setExecutable(false); + f = new File(path + ".file3"); + f.createNewFile(); + f.setExecutable(true); + // content of dir1 + f = new File(path + File.separator + "dir1" + File.separator + "file11"); + f.createNewFile(); + f.setExecutable(true); + f = new File(path + File.separator + "dir1" + File.separator + "file12"); + f.createNewFile(); + f.setExecutable(false); + f = new File(path + File.separator + "dir1" + File.separator + ".file13"); + f.createNewFile(); + f.setExecutable(true); + // content of dir2 + f = new File(path + File.separator + "dir2" + File.separator + "file21"); + f.createNewFile(); + f.setExecutable(true); + f = new File(path + File.separator + "dir2" + File.separator + "file22"); + f.createNewFile(); + f.setExecutable(false); + f = new File(path + File.separator + "dir2" + File.separator + ".file23"); + f.createNewFile(); + f.setExecutable(true); + // content of dir11 + f = new File(path + File.separator + "dir1" + File.separator + "dir11" + File.separator + "file111"); + f.createNewFile(); + f.setExecutable(true); + f = new File(path + File.separator + "dir1" + File.separator + "dir11" + File.separator + "file112"); + f.createNewFile(); + f.setExecutable(false); + f = new File(path + File.separator + "dir1" + File.separator + "dir11" + File.separator + ".file113"); + f.createNewFile(); + f.setExecutable(true); + } +} diff --git a/tp06 b/tp06 deleted file mode 160000 index a3a413d..0000000 --- a/tp06 +++ /dev/null @@ -1 +0,0 @@ -Subproject commit a3a413ddd7a02a4055d86a2a8452438bba4ab392 -- GitLab