diff --git a/DEV2.1/TP07/Etoile.class b/DEV2.1/TP07/Etoile.class new file mode 100644 index 0000000..23d1403 Binary files /dev/null and b/DEV2.1/TP07/Etoile.class differ diff --git a/DEV2.1/TP07/Etoile.java b/DEV2.1/TP07/Etoile.java new file mode 100644 index 0000000..009adde --- /dev/null +++ b/DEV2.1/TP07/Etoile.java @@ -0,0 +1,34 @@ +import java.awt.Point; + +public class Etoile implements ProducteurDePoints { + private static final int xCentre = 100; + private static final int yCentre = 100; + private static final double rayon = 90.0; + private static final double angleDepart = Math.PI/4.0; + private static final double angleIncrement = (4.0*Math.PI)/5.0; + private double numero; + public Etoile() { + this.numero = 0.0; + } + public Point suivant() { + Point p = null; + if (this.numero < 6.0) { + double angle = Etoile.angleDepart+this.numero*Etoile.angleIncrement; + p = new Point((int) (Etoile.rayon*Math.cos(angle)), + (int) (Etoile.rayon*Math.sin(angle))); + p.translate(Etoile.xCentre, Etoile.yCentre); + this.numero++; + } else { + this.numero = 0.0; + } + return p; + } + + public static void main(String[] args) { + Etoile e = new Etoile(); + while (e.suivant() != null) { + // TODO + System.out.println("Test"); + } + } +} \ No newline at end of file diff --git a/DEV2.1/TP07/Moto.class b/DEV2.1/TP07/Moto.class new file mode 100644 index 0000000..783742d Binary files /dev/null and b/DEV2.1/TP07/Moto.class differ diff --git a/DEV2.1/TP07/Moto.java b/DEV2.1/TP07/Moto.java new file mode 100644 index 0000000..06325f3 --- /dev/null +++ b/DEV2.1/TP07/Moto.java @@ -0,0 +1,11 @@ +public class Moto implements Vehicule { + + public String sorte() { + return "Moto"; + } + + public int nbRoues() { + return 2; + } + +} \ No newline at end of file diff --git a/DEV2.1/TP07/Moyenne.class b/DEV2.1/TP07/Moyenne.class new file mode 100644 index 0000000..f49ad7a Binary files /dev/null and b/DEV2.1/TP07/Moyenne.class differ diff --git a/DEV2.1/TP07/Moyenne.java b/DEV2.1/TP07/Moyenne.java new file mode 100644 index 0000000..a348c05 --- /dev/null +++ b/DEV2.1/TP07/Moyenne.java @@ -0,0 +1,28 @@ +public class Moyenne { + private double moyenne; + private int compteur; + + public Moyenne() { + this.moyenne = 0; + this.compteur = 0; + } + + public double add(Number n) { + this.compteur++; + return this.moyenne += n.doubleValue(); + } + + public double getAverage() { + return this.moyenne / this.compteur; + } + + + + public static void main(String[] args) { + Moyenne m = new Moyenne(); + m.add(2); + m.add(5.4); + m.add(547L); + System.out.println(m.getAverage()); + } +} \ No newline at end of file diff --git a/DEV2.1/TP07/MoyenneV1.class b/DEV2.1/TP07/MoyenneV1.class new file mode 100644 index 0000000..9bfca20 Binary files /dev/null and b/DEV2.1/TP07/MoyenneV1.class differ diff --git a/DEV2.1/TP07/MoyenneV1.java b/DEV2.1/TP07/MoyenneV1.java new file mode 100644 index 0000000..88a43d1 --- /dev/null +++ b/DEV2.1/TP07/MoyenneV1.java @@ -0,0 +1,53 @@ +public class MoyenneV1 { + private double moyenne; + private int compteur; + + public MoyenneV1() { + this.moyenne = 0; + this.compteur = 0; + } + + public double add(byte n) { + this.compteur++; + return this.moyenne += n; + } + + public double add(short n) { + this.compteur++; + return this.moyenne += n; + } + + public double add(int n) { + this.compteur++; + return this.moyenne += n; + } + + public double add(long n) { + this.compteur++; + return this.moyenne += n; + } + + public double add(float n) { + this.compteur++; + return this.moyenne += n; + } + + public double add(double n) { + this.compteur++; + return this.moyenne += n; + } + + public double getAverage() { + return this.moyenne / this.compteur; + } + + + + public static void main(String[] args) { + MoyenneV1 m = new MoyenneV1(); + m.add(2); + m.add(5.4); + m.add(547L); + System.out.println(m.getAverage()); + } +} \ No newline at end of file diff --git a/DEV2.1/TP07/ProducteurDePoints.class b/DEV2.1/TP07/ProducteurDePoints.class new file mode 100644 index 0000000..860e678 Binary files /dev/null and b/DEV2.1/TP07/ProducteurDePoints.class differ diff --git a/DEV2.1/TP07/ProducteurDePoints.java b/DEV2.1/TP07/ProducteurDePoints.java new file mode 100644 index 0000000..4c0dd33 --- /dev/null +++ b/DEV2.1/TP07/ProducteurDePoints.java @@ -0,0 +1,5 @@ +import java.awt.Point; + +public interface ProducteurDePoints { + Point suivant(); +} \ No newline at end of file diff --git a/DEV2.1/TP07/Test.class b/DEV2.1/TP07/Test.class new file mode 100644 index 0000000..fc11390 Binary files /dev/null and b/DEV2.1/TP07/Test.class differ diff --git a/DEV2.1/TP07/Test.java b/DEV2.1/TP07/Test.java new file mode 100644 index 0000000..004186b --- /dev/null +++ b/DEV2.1/TP07/Test.java @@ -0,0 +1,22 @@ +import javax.swing.JOptionPane; + +public class Test { + public static void main(String[] args) { + Vehicule v; + Object[] choix = {"Voiture", "Moto"}; + + int reponse = JOptionPane.showOptionDialog(null, + "Quel v\u00E9hicule choisissez-vous ?", + "Question", + JOptionPane.DEFAULT_OPTION, + JOptionPane.QUESTION_MESSAGE, + null, + choix, + null); + if (reponse == 0) + v = new Voiture(); + else + v = new Moto(); + System.out.println("Une "+v.sorte()+" poss\u00E8de "+v.nbRoues()+" roues."); + } +} \ No newline at end of file diff --git a/DEV2.1/TP07/Vehicule.class b/DEV2.1/TP07/Vehicule.class new file mode 100644 index 0000000..fbc9421 Binary files /dev/null and b/DEV2.1/TP07/Vehicule.class differ diff --git a/DEV2.1/TP07/Vehicule.java b/DEV2.1/TP07/Vehicule.java new file mode 100644 index 0000000..f7604d5 --- /dev/null +++ b/DEV2.1/TP07/Vehicule.java @@ -0,0 +1,6 @@ +public interface Vehicule { + + public String sorte(); + + public int nbRoues(); +} \ No newline at end of file diff --git a/DEV2.1/TP07/Voiture.class b/DEV2.1/TP07/Voiture.class new file mode 100644 index 0000000..76c4ec2 Binary files /dev/null and b/DEV2.1/TP07/Voiture.class differ diff --git a/DEV2.1/TP07/Voiture.java b/DEV2.1/TP07/Voiture.java new file mode 100644 index 0000000..9a9bc1e --- /dev/null +++ b/DEV2.1/TP07/Voiture.java @@ -0,0 +1,11 @@ +public class Voiture implements Vehicule { + + public String sorte() { + return "Voiture"; + } + + public int nbRoues() { + return 4; + } + +} \ No newline at end of file