

class Nov19 {
	public static void main(String[] args) {

		Box[] array = new Box[4];
		int count = 0;

		System.out.println();
		for(Box b : array) {
			System.out.println(b);
		}

		for(int i = 0; i < 3; i++) {
			array[i] = new Box(i+1, i+1, i+1);
			count++;
		}
	
		System.out.println();
		for(Box b : array) {
			System.out.println(b);
		}

		if(removeBox(array, 2, 2, 2) == true) {
			count--;
		}

		System.out.println();
		System.out.printf("count: %d\n", count);
		for(Box b : array) {
			System.out.println(b);
		}

		array = expand(array);

		System.out.println();
		for(Box b : array) {
			System.out.println(b);
		}

	}
	
	/* attempts to remove first instance box with given dimensions from 
	   array. Returns true if box is removed; false otherwise
	*/
	static boolean removeBox(Box[] arr, int l, int w, int h) {
		Box temp = new Box(l,w,h);

		for(int i = 0; i < arr.length; i++) {
			Box b = arr[i];
			if(b.equals(temp)) {
				arr[i] = null;
				for(int j = i+1; j < arr.length; j++) {
					Box t = arr[j-1];
					arr[j-1] = arr[j];
					arr[j] = t;
				}
			
				return true;
			}			
		}
		return false;
	}

	static Box[] expand(Box[] orig) {
		int length = orig.length * 2;
		Box[] newArray = new Box[length];

		for(int i = 0; i < orig.length; i++) {
			newArray[i] = orig[i];
		}
		
		return newArray;
	}



}


