package inherShapes;

public class Rectangle extends Shape {

	private double width;
	private double height;

	public Rectangle(Point ll, double width, double height) {
		super(ll);
		this.width=width;
		this.height=height;
	}

	public Point max() { return new Point(ll.getX() + width,ll.getY() + height); }

	public double perimiter() { return 2*(width+height); }
	public double area() { return width * height; }

	@Override public String toString() {
		return super.toString() + " w=" + width + " h=" + height;
	}

	@Override public boolean equals(Object obj) {
		if (!(obj instanceof Rectangle)) return false;
		Rectangle r = (Rectangle) obj;
		return (super.equals(r) && r.width==this.width && r.height == this.height);
	}

	@Override public int hashCode() {
		Double widthBoxed = width;
		Double heightBoxed = height;
		return super.hashCode() + widthBoxed.hashCode() + heightBoxed.hashCode();
	}

}