public class Rectangle {
    // La clase Rectangle de toda la vida.
    private final OverloadedPoint p1;
    private final OverloadedPoint p2;
    public Rectangle(OverloadedPoint p1, OverloadedPoint p2) {
        this.p1 = p1;
        this.p2 = p2;
    }
    public OverloadedPoint getP1() {
        return this.p1;
    }
    public OverloadedPoint getP2() {
        return this.p2;
    }
    public double calculateArea() {
        return (Math.abs(this.p1.getX() - this.p2.getX())
                * Math.abs(this.p1.getY() - this.p2.getY()));
        // You cannot access this.p1.x directly cos it's private
    }
    public double calculatePerimeter() {
        return (2 * (Math.abs(this.p1.getX() - this.p2.getX())
                + Math.abs(this.p1.getY() - this.p2.getY())));
        // You cannot access this.p1.x directly cos it's private
    }
    @Override
    public String toString() {
        // return "(" + this.p1 + "," + this.p2 + ")";
        return "(" + this.p1.toString("P1") + ", " +
                this.p2.toString("P2") + ")";
    }
}
