Add cut/copy/paste to the main windows menu.
[Persons_Comparator.git] / src / Size.java
1 public class Size implements Comparable<Size> {
2 private int max = 240;
3 private int min = 20;
4 private int size;
5
6 Size() {
7 }
8
9 Size(int size) {
10 setSize(size);
11 }
12
13 public int getSize() {
14 return size;
15 }
16
17 public void setSize(int size) {
18 if (validateSize(size)) {
19 this.size = size;
20 } else {
21 throw new IllegalArgumentException("Size must be between " + this.min + " and " + this.max);
22 }
23 }
24
25 private boolean validateSize(int size) {
26 return (size >= min && size <= max);
27 }
28
29 @Override
30 public int compareTo(Size size) {
31 int distance = size.getSize() - this.getSize();
32 if (distance >= 0)
33 return distance;
34 else
35 return -distance;
36
37 }
38 }