repositories
/
Persons_Comparator.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Implement the person comparator :
[Persons_Comparator.git]
/
src
/
Size.java
diff --git
a/src/Size.java
b/src/Size.java
index 0cecada6c98192f7cfa94f874f937e1fe9831276..eb8003f542104a9249658a2b118a8f758c0f8814 100644
(file)
--- a/
src/Size.java
+++ b/
src/Size.java
@@
-1,13
+1,28
@@
-
public class Size {
private int max = 240;
public class Size {
private int max = 240;
- private int min = 20;
+ private int min = 40;
+ private int defaultSize = 160;
private int size;
private int size;
+ Size() {
+ }
+
Size(int size) {
setSize(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;
}
public int getSize() {
return size;
}
@@
-15,10
+30,17
@@
public class Size {
public void setSize(int size) {
if (validateSize(size)) {
this.size = size;
public void setSize(int size) {
if (validateSize(size)) {
this.size = size;
- } /* FIXME: raise an error */
+ } else {
+ throw new IllegalArgumentException("Size must be between " + this.getMin() + " and " + this.getMax());
+ }
}
private boolean validateSize(int size) {
}
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);
}
}
}
}