import java.util.Comparator;

/**  
 * A very simple interface to experiment with -- representing a closed planar
 * shape.
 *
 * @see Circle.java
 * @see Rectangle.java
 * @see MeasuringStuff.java
 *
 * @author Mark Young (A00000000)
 */
public interface Measurable {

    /** 
     * Get this object's area. 
     *
     * @return this object's area
     */
    public double getArea();

    /** 
     * Get this object's perimeter. 
     *
     * @return this object's perimeter
     */
    public double getPerimeter();

    /**
     * Calculate this object's roundness. The range of values returned is from
     * zero to one. Circles are perfectly round (1.0), while lines are not
     * round at all (0.0). Squares are moderately round (&Pi; / 4 &approx; 
     * 0.785).
     *
     * @return how round this object is
     */
    public default double getRoundness() {
        return 4.0 * Math.PI * getArea() / Math.pow(getPerimeter(), 2);
    }

    /**
     * Compare objects by their areas.
     */
    public static final Comparator<Measurable> BY_AREA = (one, other)
            -> Double.compare(one.getArea(), other.getArea());

    /**
     * Compare objects by their perimetera.
     */
    public static final Comparator<Measurable> BY_PERIMETER = (one, other)
            -> Double.compare(one.getPerimeter(), other.getPerimeter());

}

