Add the abstract class Forme that Cercle and Segment extend.
[TP_POO.git] / TP2 / Segment.java
index 941820c4ac728add80b4eaff85613f4c70a51221..25dc5e47e50c2b6d41b66a55a632bdc4a8bd13e6 100644 (file)
@@ -1,5 +1,5 @@
 
-class Segment {
+class Segment extends Forme {
     private Point pOri;
     private Point pDest;
 
@@ -13,12 +13,17 @@ class Segment {
         pDest = pD;
     }
 
-    void dessiner(Piletransformations pile) {
-
+    public void dessiner(Piletransformations pile) {
+        String className = this.getClass().getSimpleName();
+        Point pTrans = pile.getCurrentTransformation();
+        Point pOriTrans = pOri.additionner(pTrans);
+        Point pDestTrans = pDest.additionner(pTrans);
+        System.out.println(className + " " + pOri.toString()+ "->" + pOriTrans.toString() + " " + pDest.toString() + "->" + pDestTrans.toString());
     }
 
-    void deplacer(Point p) {
-
+    public void deplacer(Point p) {
+        pOri = pOri.additionner(p);
+        pDest = pDest.additionner(p);
     }
 
 }