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