From 36a82657f0caabbe4abcf2153dff10014e2119b8 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=B4me=20Benoit?= Date: Mon, 5 Mar 2018 10:10:50 +0100 Subject: [PATCH] TP2: Implement the Image class as a Comparator 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 | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/TP2/Image.java b/TP2/Image.java index da90314..d508e75 100644 --- a/TP2/Image.java +++ b/TP2/Image.java @@ -1,5 +1,6 @@ +import java.util.Comparator; -class Image extends Forme implements Compactable, Comparable { +public class Image extends Forme implements Compactable, Comparable, Comparator { final int IMAGE_MAX_SIZE = 100; Forme[] formeCollection; int formeNumber; @@ -88,4 +89,8 @@ class Image extends Forme implements Compactable, Comparable { return formeNumber - image.getSize(); } + public int compare(Image image1, Image image2) { + return image1.getSize() - image2.getSize(); + } + } -- 2.34.1