From: Jérôme Benoit Date: Wed, 14 Feb 2018 16:54:02 +0000 (+0100) Subject: Fix the Image adding function. X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=f8ac3cd5d95e357a26fd58f38db91babdddb9673;p=TP_POO.git Fix the Image adding function. Signed-off-by: Jérôme Benoit --- diff --git a/TP2/Image.java b/TP2/Image.java index ac66870..8f10393 100644 --- a/TP2/Image.java +++ b/TP2/Image.java @@ -41,7 +41,7 @@ class Image extends Forme { boolean rtVal = false; if (!isFull()) { formeCollection[formeNumber] = forme; - formeNumber = 0; + formeNumber++; rtVal = true; } return rtVal; diff --git a/TP2/Main.java b/TP2/Main.java index e05593a..2abace9 100644 --- a/TP2/Main.java +++ b/TP2/Main.java @@ -6,36 +6,20 @@ class Main { Point p1 = new Point(1, 2); Point p2 = new Point(2, 7); - Point p3 = p1.additionner(p2); - - System.out.println(p1.toString()); - System.out.println(p2.toString()); - System.out.println(p3.toString()); - - Point p4 = new Point(4, 5); - Point p5 = new Point(2, 3); - Segment segment = new Segment(p4, p5); - Cercle cercle = new Cercle(p4, 5.2); - + Segment segment = new Segment(p1, p2); + Point p3 = new Point(4, 5); + Cercle cercle = new Cercle(p3, 5.2); + Point p4 = new Point(2, 3); Piletransformations trans = new Piletransformations(10); - trans.display(); - - segment.dessiner(trans); - cercle.dessiner(trans); - boolean rt = trans.empiler(p1); - trans.display(); - segment.dessiner(trans); - cercle.dessiner(trans); - rt = trans.empiler(p2); - trans.display(); - segment.dessiner(trans); - cercle.dessiner(trans); + boolean rt = trans.empiler(p4); - segment.deplacer(p1); - cercle.deplacer(p1); segment.dessiner(trans); cercle.dessiner(trans); + Image image = new Image(); + image.ajouter(segment); + image.ajouter(cercle); + image.dessiner(trans); } } diff --git a/TP2/Point.java b/TP2/Point.java index 049c6a2..5a591c6 100644 --- a/TP2/Point.java +++ b/TP2/Point.java @@ -5,7 +5,7 @@ class Point { Point() { /* - * FIXME: init to (0,0)? + * FIXME: init to (0,0)? */ } diff --git a/TP2/Segment.java b/TP2/Segment.java index 25dc5e4..a421af7 100644 --- a/TP2/Segment.java +++ b/TP2/Segment.java @@ -18,7 +18,8 @@ class Segment extends Forme { 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()); + System.out.println(className + " " + pOri.toString()+ "->" + pOriTrans.toString() + " " + + pDest.toString() + "->" + pDestTrans.toString()); } public void deplacer(Point p) {