public class Rectangle { // Con multiples constructores
    private final Point p1;
    private final Point p2;
    public Rectangle(Point p1, Point p2) {
        this.p1 = p1;
        this.p2 = p2;
    }
    public Rectangle(Point p1) {
        this(p1, Point.POINT_ZERO); // Best practice
        /*
        // Esto tambien funcionaria.
        this.p1 = p1;
        this.p2 = Point.POINT_ZERO;
         */
    }
    public Rectangle() {
        this(Point.POINT_ZERO); // Best practice
        // this(Point.POINT_ZERO, Point.POINT_ZERO); // OK
        /*
        // Esto tambien funcionaria.
        this.p1 = Point.POINT_ZERO;
        this.p2 = Point.POINT_ZERO;
         */
    }
    public Point getP1() {
        return this.p1;
    }
    public Point 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 + ")";
    }
}
