diff --git a/DEV2.1/TP2/Compteur.class b/DEV2.1/TP2/Compteur.class new file mode 100644 index 0000000..b6456a2 Binary files /dev/null and b/DEV2.1/TP2/Compteur.class differ diff --git a/DEV2.1/TP2/Compteur.java b/DEV2.1/TP2/Compteur.java new file mode 100644 index 0000000..8ba51e0 --- /dev/null +++ b/DEV2.1/TP2/Compteur.java @@ -0,0 +1,29 @@ +public class Compteur +{ + private int compte; + + public Compteur(int start) + { + this.compte = start; + } + + public void plusUn() + { + this.compte++; + } + + public String toString() + { + return Integer.toBinaryString(this.compte); + } + + public static void main(String[] args) + { + Compteur test = new Compteur(5); + while (test.compte<10) + { + System.out.println(test.toString()); + test.plusUn(); + } + } +} diff --git a/DEV2.1/TP2/Date.class b/DEV2.1/TP2/Date.class new file mode 100644 index 0000000..b676e93 Binary files /dev/null and b/DEV2.1/TP2/Date.class differ diff --git a/DEV2.1/TP2/Date.java b/DEV2.1/TP2/Date.java new file mode 100644 index 0000000..0d1792b --- /dev/null +++ b/DEV2.1/TP2/Date.java @@ -0,0 +1,79 @@ +public class Date +{ + private int jour; + private int mois; + private int annee; + + public Date(int a, int m, int j) + { + this.jour = j; + this.mois = m; + this.annee = a; + } + + public String lendemain() + { + if (this.jour<30) + { + return this.annee+"-"+this.mois+"-"+(this.jour+1); + } + else + { + if (this.mois<12) + { + return this.annee+"-"+(this.mois+1)+"-1"; + } + else + { + return (this.annee+1)+"-1-1"; + } + } + } + + public String toString() + { + return this.annee+"-"+this.mois+"-"+this.jour; + } + + public int datecmp(Date other) + { + if (this.annee==other.annee&&this.mois==other.mois&&this.jour==other.jour) + { + return 0; + } + else + { + if (this.annee>other.annee) + { + return 1; + } + else + { + if (this.mois>other.mois) + { + return 1; + } + else + { + if (this.jour>other.jour) + { + return 1; + } + else + { + return -1; + } + } + } + } + } + + + + public static void main(String[] args) + { + Date test = new Date(2023,12,30); + System.out.println(test.toString()); + System.out.println(test.lendemain()); + } +} diff --git a/DEV2.1/TP2/Periode.java b/DEV2.1/TP2/Periode.java new file mode 100644 index 0000000..a290d31 --- /dev/null +++ b/DEV2.1/TP2/Periode.java @@ -0,0 +1,10 @@ +public class Periode +{ + private int jour; + + public Periode(int j) + { + this.jour = j; + } + +}