/** Numeric interval -- closed intervals */ class Interval { private double base; // low end private double width; // interval width /** Constructor: An Interval has base b and width w */ public Interval(double base, double w) { this.base= base; width= w; } /** Constructor: An Interval with base 0 and width w */ public Interval(double w) { this(0,w); } /** Constructor: An Interval with initial values given by declarations */ public Interval() {} /** =Get left end of interval */ public double getBase() { return base; } /** =Get right end of interval */ public double getEnd() { return base + width; } /** Set left end of interval to base */ public void setBase(double base) { this.base= base; } /** Set width of interval to w */ public void setWidth(double w) { width = w; } /** =String description of Interval */ public String toString(){ return "[" + getBase() + "," + getEnd() + "]"; } /** Expand this Interval by a factor of f (expand to the right) */ public void expand(double f) { setWidth(width*f); } /** =“this Interval is in i” */ public boolean isIn(Interval i) { return ( getBase()>=i.getBase() && getEnd()<=i.getEnd() ); } }