TP2: Simplify chained conditions.
[TP_POO.git] / TP2 / Segment.java
CommitLineData
4871c009 1
bd443eec 2class Segment extends Forme {
4871c009
JB
3 private Point pDest;
4
5 /* Segment() {
6 pOri = null;
7 pDest = null;
8 } */
9
10 Segment(Point pO, Point pD) {
009c5b1e 11 super(pO);
4871c009
JB
12 pDest = pD;
13 }
14
14d4fd0d
JB
15 public void dessiner(Piletransformations pile) {
16 String className = this.getClass().getSimpleName();
17 Point pTrans = pile.getCurrentTransformation();
009c5b1e 18 Point pOriTrans = super.getpOri().additionner(pTrans);
14d4fd0d 19 Point pDestTrans = pDest.additionner(pTrans);
009c5b1e 20 System.out.println(className + " " + super.getpOri().toString()+ "->" + pOriTrans.toString() + " " +
f8ac3cd5 21 pDest.toString() + "->" + pDestTrans.toString());
4871c009
JB
22 }
23
14d4fd0d 24 public void deplacer(Point p) {
009c5b1e 25 super.deplacer(p);
14d4fd0d 26 pDest = pDest.additionner(p);
4871c009
JB
27 }
28
54d3f5b3 29 public void afficher() {
c7c510eb
JB
30 String className = this.getClass().getSimpleName();
31 System.out.println("---- " + className + " ----");
54d3f5b3
JB
32 System.out.println(super.getpOri().toString() + " " + pDest.toString());
33 }
34
4871c009 35}