View Javadoc

1   package SocialSteeringsBeta;
2   
3   /**
4    * @author Petr
5    */
6   public class Interval {
7       private int min;
8       private int max;
9   
10      public Interval(int mn, int mx) {
11          min = mn;
12          max = mx;
13      }
14  
15      public boolean in(int x) {
16          return x >= min && x <= max;
17      }
18      
19      public boolean in(int x,double tolerance) {
20          return x+tolerance >= min && x-tolerance <= max;
21      }
22  
23      public int avg() {
24          return (min + max) / 2;
25      }
26  
27      public int getMax() {
28          return max;
29      }
30      
31       public int getMin() {
32          return min;
33      }
34  }