X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2FSize.java;h=eb8003f542104a9249658a2b118a8f758c0f8814;hb=5687dc10a68b52d28b63151d8c16a45775ef2e77;hp=dfea96cdd8226c8dba12b50fa86423ceb2635658;hpb=bcdec88755a4a44882edfbb96581294f77a6e1ed;p=Persons_Comparator.git diff --git a/src/Size.java b/src/Size.java index dfea96c..eb8003f 100644 --- a/src/Size.java +++ b/src/Size.java @@ -1,13 +1,28 @@ - public class Size { private int max = 240; - private int min = 20; + private int min = 40; + private int defaultSize = 160; private int size; + Size() { + } + Size(int size) { setSize(size); } + public int getMin() { + return min; + } + + public int getMax() { + return max; + } + + public int getDefaultSize() { + return defaultSize; + } + public int getSize() { return size; } @@ -16,11 +31,16 @@ public class Size { if (validateSize(size)) { this.size = size; } else { - throw new IllegalArgumentException("Size must be between" + this.min + " and " + this.max); + throw new IllegalArgumentException("Size must be between " + this.getMin() + " and " + this.getMax()); } } private boolean validateSize(int size) { - return (size > max || size < min); + return (size >= getMin() && size <= getMax()); + } + + public int distanceTo(Size size) { + int distance = size.getSize() - this.getSize(); + return Math.abs(distance); } }