exo4: Add the code skeleton coming from TP2.
[Project_POO.git] / exo4 / Segment.java
diff --git a/exo4/Segment.java b/exo4/Segment.java
new file mode 100644 (file)
index 0000000..2ec075c
--- /dev/null
@@ -0,0 +1,35 @@
+
+class Segment extends Forme {
+    private Point pDest;
+
+    /* Segment() {
+        pOri = null;
+        pDest = null;
+    } */
+
+    Segment(Point pO, Point pD) {
+        super(pO);
+        pDest = pD;
+    }
+
+    public void dessiner(Piletransformations pile) {
+        String className = this.getClass().getSimpleName();
+        Point pTrans = pile.getCurrentTransformation();
+        Point pOriTrans = super.getpOri().additionner(pTrans);
+        Point pDestTrans = pDest.additionner(pTrans);
+        System.out.println(className + " " + super.getpOri().toString()+ "->" + pOriTrans.toString() + " " +
+                           pDest.toString() + "->" + pDestTrans.toString());
+    }
+
+    public void deplacer(Point p) {
+        super.deplacer(p);
+        pDest = pDest.additionner(p);
+    }
+
+    public void afficher() {
+        String className = this.getClass().getSimpleName();
+        System.out.println("---- " + className + " ----");
+        System.out.println(super.getpOri().toString() + " " + pDest.toString());
+    }
+
+}