public class Rectangle {

	private final Point p1;
	private final Point p2;

	public Rectangle(Point p1, Point p2) {
		this.p1 = p1;
		this.p2 = p2;
	}

	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
	}

	public String toString() {
		return "(" + this.p1 + "," + this.p2 + ")"; 
	}
}
