From: Jérôme Benoit Date: Mon, 5 Mar 2018 09:10:50 +0000 (+0100) Subject: TP2: Implement the Image class as a Comparator interface. X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=36a82657f0caabbe4abcf2153dff10014e2119b8;p=TP_POO.git TP2: Implement the Image class as a Comparator interface. Signed-off-by: Jérôme Benoit --- 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(); + } + }