From 1ace87363eeb14dfad101401fa0fbf1dfb5c5105 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=B4me=20Benoit?= Date: Mon, 5 Mar 2018 09:46:25 +0100 Subject: [PATCH] TP2: Implement Image class as a Comparable interface. MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Jérôme Benoit --- TP2/Image.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/TP2/Image.java b/TP2/Image.java index 8289930..da90314 100644 --- a/TP2/Image.java +++ b/TP2/Image.java @@ -1,5 +1,5 @@ -class Image extends Forme implements Compactable { +class Image extends Forme implements Compactable, Comparable { final int IMAGE_MAX_SIZE = 100; Forme[] formeCollection; int formeNumber; @@ -16,6 +16,10 @@ class Image extends Forme implements Compactable { formeNumber = 0; } + public int getSize() { + return formeNumber; + } + private boolean isEmpty() { return (formeNumber == 0); } @@ -80,4 +84,8 @@ class Image extends Forme implements Compactable { } } + public int compareTo(Image image) { + return formeNumber - image.getSize(); + } + } -- 2.34.1