/** Numeric interval -- closed intervals
 */
class Interval {

  private double base;  // low end
  private double width; // interval width
   
  /** Constructor: An Interval has a specified base and width w */
  public Interval(double base, double w) {
    this.base= base;
    setWidth(w);
  }
  
  /** =Get right end of this Interval */
  public double getEnd() { return base + width; }
  
  /** =Get base of this Interval */
  public double getBase() { return base; }
  
  /** Set width of this Interval to w */
  public void setWidth(double w) { width= w; }
  
  /** Expand this Interval by a factor of f (expand to the right) */
  public void expand(double f) {
    setWidth(width*f);
  }

  /** ={This Interval is in Interval i}
   *  If the ends of this Interval and i are exactly equal, consider
   *  this Interval to be in i.
   */
  public boolean isIn(Interval i) {
    return ( getBase()>=i.getBase() && getEnd()<=i.getEnd() );
  }

  /** =String description of this Interval */
  public String toString(){
    return "[" + getBase() + "," + getEnd() + "]";
  }
  
} //class Interval

