Add the basic code for Image handling.
authorJérôme Benoit <jerome.benoit@piment-noir.org>
Wed, 14 Feb 2018 11:16:02 +0000 (12:16 +0100)
committerJérôme Benoit <jerome.benoit@piment-noir.org>
Wed, 14 Feb 2018 11:16:02 +0000 (12:16 +0100)
Signed-off-by: Jérôme Benoit <jerome.benoit@piment-noir.org>
TP2/Image.java [new file with mode: 0644]
TP2/Makefile

diff --git a/TP2/Image.java b/TP2/Image.java
new file mode 100644 (file)
index 0000000..807e11b
--- /dev/null
@@ -0,0 +1,44 @@
+
+class Image extends Forme {
+    final int IMAGE_MAX_SIZE = 100;
+    Point pOri;
+    Forme[] formeCollection;
+    int formeNumber;
+
+    Image() {
+        pOri = new Point();
+        formeCollection = new Forme[IMAGE_MAX_SIZE];
+        formeNumber = 0;
+    }
+
+    Image(Point p) {
+        pOri = p;
+        formeCollection = new Forme[IMAGE_MAX_SIZE];
+        formeNumber = 0;
+    }
+
+    private boolean isEmpty() {
+        return (formeNumber == 0);
+    }
+
+    private boolean isFull() {
+        return (formeNumber >= formeCollection.length);
+    }
+
+    public void dessiner(Piletransformations pile) {
+        for (int i = 0; i < formeNumber; i++) {
+            formeCollection[i].dessiner(pile);
+        }
+    }
+
+    public void deplacer(Point p) {
+        for (int i = 0; i < formeNumber; i++) {
+            formeCollection[i].deplacer(p);
+        }
+    }
+
+    public boolean ajouter(Forme forme) {
+        return false;
+    }
+
+}
index 14f1b59dd1af0fa7ff4e0ad52cdd7db7c3bcce7c..41023ffc3a6f7e2c0d63ca70336eac643cd45f49 100644 (file)
@@ -48,6 +48,7 @@ JVM = java
 CLASSES = \
         Point.java \
                Forme.java \
+               Image.java \
                Segment.java \
                Cercle.java \
                Piletransformations.java \