source: src/main/java/negotiator/boaframework/opponentmodel/nash/Range.java

Last change on this file was 127, checked in by Wouter Pasman, 6 years ago

#41 ROLL BACK of rev.126 . So this version is equal to rev. 125

File size: 1.8 KB
Line 
1package negotiator.boaframework.opponentmodel.nash;
2
3/**
4 *
5 * This class represents a range for decimal values. It offers a lower- and upperbound
6 * that indicate the boundaries of the range.
7 *
8 * @author Roland van der Linden
9 *
10 */
11public class Range
12{
13 // ********************************************
14 // Fields
15 // ********************************************
16
17 public double lowerbound, upperbound;
18
19
20 // ********************************************
21 // Constructor & init
22 // ********************************************
23
24 /**
25 * This constructs the range with both boundaries set to zero.
26 */
27 public Range()
28 {
29 this(0, 0);
30 }
31
32 /**
33 * This constructs the range with the specified boundaries.
34 * @param lowerbound The lowerbound of the range.
35 * @param upperbound The upperbound of the range.
36 */
37 public Range(double lowerbound, double upperbound)
38 {
39 this.lowerbound = lowerbound;
40 this.upperbound = upperbound;
41 }
42
43
44 // ********************************************
45 // Other methods.
46 // ********************************************
47
48 /**
49 * This returns the length of the range.
50 * @return
51 */
52 public double getLength()
53 {
54 return this.upperbound - this.lowerbound;
55 }
56
57 /**
58 * This method specifies whether or not the given value falls within the boundaries
59 * of this range. Note that both boundary values are INCLUSIVE.
60 * @param value The value to test for if it is within the range.
61 * @return True if the value is within the range.
62 */
63 public boolean withinBounds(double value)
64 {
65 return (value >= this.lowerbound && value <= this.upperbound);
66 }
67
68 /**
69 * A String representation of the range.
70 */
71 public String toString()
72 {
73 return "(" + lowerbound + ", " + ")";
74 }
75}
Note: See TracBrowser for help on using the repository browser.