
class Box implements Comparable<Box> {

	protected double height = 0;
	protected double width = 0;
	protected double length = 0;
	protected double volume = 0;

	public Box(double h, double w, double l) {
		this.height = h;
		this.width = w;
		this.length = l;

		volume = h * w * l;
	}

	public double getHeight() {
		return height;
	}

	public double getWidth() {
		return width;
	}

	public double getLength() {
		return length;
	}

	public double getVolume() {
		return volume;
	}

	public String toString() {
		return String.format("(H:%.2f, W:%.2f, L:%.2f, V:%.2f)", height, width, length, volume);
	}
	
	@Override
	public boolean equals(Object obj) {
		if (!(obj instanceof Box)) {
			return false;
		}

		Box that = (Box) obj;

		return (Double.compare(this.height, that.height) == 0 &&
			Double.compare(this.width, that.width) == 0 &&
			Double.compare(this.length, that.length) == 0);
	}

	@Override
	public int hashCode() {
		int result = 17;
		
		long l = Double.doubleToLongBits(height);
		result += 31 * result + (int) (l ^ (l >>> 32)); 

		l = Double.doubleToLongBits(width);
		result += 31 * result + (int) (l ^ (l >>> 32)); 

		l = Double.doubleToLongBits(length);
		result += 31 * result + (int) (l ^ (l >>> 32)); 

		return result;
	}

	public int compareTo(Box that) {
		return Double.compare(this.volume,that.volume);	
	}

}
