Inf1 OP : Lab Sheet Week 7 Q4 - Interval
Overview

The aim of this question is to create a class Interval which represents an interval of the real numbers. For example, the closed interval [2.5, 5.0] would represent all the numbers between 2.5 and 5.0 inclusive.

Implement a class Interval with the following API:

public Interval(double left, double right)
Class constructor. The values of left and right are the two endpoints of the interval.
public boolean doesContain(double x)
Returns true if and only if x lies between left and right, and the interval is not empty (i.e. left < right).
public boolean isEmpty()
Returns true if and only if left is larger than right.
public boolean intersects(Interval b)
Returns true if and only if the Interval b intersects with this interval. Note that empty intervals can’t intersect with other intervals.
public String toString()
Returns a string summarising the Interval; for example "Interval: [2.5, 5.0]" or "Interval: (EMPTY)".

An automated test has been created for this exercise: IntervalTest.java.