package CookieCutter.g1;

import CookieCutter.*;

public class Box {
	private Vertex mLeftTop;
	private Vertex mRightBottom;	
	
	public Box(double iLeft, double iTop, double iRight, double iBottom) {
		mLeftTop = new Vertex(iLeft, iTop);
		mRightBottom = new Vertex(iRight, iBottom);
	}
	
	public boolean intersects(Box iB) {
		
		if (mRightBottom.xpos() < iB.mLeftTop.xpos()) {
			return false;
		}

		if (mRightBottom.ypos() > iB.mLeftTop.ypos()) {
			return false;
		}
		
		if (mLeftTop.xpos() > iB.mRightBottom.xpos()) {
			return false;
		}		

		if (mLeftTop.ypos() < iB.mRightBottom.ypos()) {
			return false;
		}		
		
		return true;
	}
	
	public double getArea() {
		return Math.abs((mRightBottom.xpos() - mLeftTop.xpos()) *
			(mLeftTop.ypos() - mRightBottom.ypos()));
	}
	
	public double getWidth() {
		return Math.abs(mRightBottom.xpos() - mLeftTop.xpos());
	}
	
	/**
	 * @return
	 */
	public double getBottom() {
		return mRightBottom.ypos();
	}

	/**
	 * @return
	 */
	public double getLeft() {
		return mLeftTop.xpos();
	}

	/**
	 * @return
	 */
	public double getRight() {
		return mRightBottom.xpos();
	}

	/**
	 * @return
	 */
	public double getTop() {
		return mLeftTop.ypos();
	}

	/**
	 * @return
	 */
	public Vertex getBottomRight() {
		return mRightBottom;
	}

	/**
	 * @return
	 */
	public Vertex getTopLeft() {
		return mLeftTop;
	}
	
	/**
	 * @return
	 */
	public double getHeight() {
		return Math.abs(getTop() - getBottom());
	}

}
