| 1 | |
| 2 | @ClassPreamble ( |
| 3 | author = "Jérôme Benoit", |
| 4 | date = "04/25/2014" |
| 5 | ) |
| 6 | class Segment extends Forme { |
| 7 | private Point pDest; |
| 8 | |
| 9 | /* Segment() { |
| 10 | pOri = null; |
| 11 | pDest = null; |
| 12 | } */ |
| 13 | |
| 14 | Segment(Point pO, Point pD) { |
| 15 | super(pO); |
| 16 | pDest = pD; |
| 17 | } |
| 18 | |
| 19 | public void dessiner(Piletransformations pile) { |
| 20 | String className = this.getClass().getSimpleName(); |
| 21 | Point pTrans = pile.getCurrentTransformation(); |
| 22 | Point pOriTrans = super.getpOri().additionner(pTrans); |
| 23 | Point pDestTrans = pDest.additionner(pTrans); |
| 24 | System.out.println(className + " " + super.getpOri().toString()+ "->" + pOriTrans.toString() + " " + |
| 25 | pDest.toString() + "->" + pDestTrans.toString()); |
| 26 | } |
| 27 | |
| 28 | public void deplacer(Point p) { |
| 29 | super.deplacer(p); |
| 30 | pDest = pDest.additionner(p); |
| 31 | } |
| 32 | |
| 33 | public void afficher() { |
| 34 | String className = this.getClass().getSimpleName(); |
| 35 | System.out.println("---- " + className + " ----"); |
| 36 | System.out.println(super.getpOri().toString() + " " + pDest.toString()); |
| 37 | } |
| 38 | |
| 39 | } |