this is a homework assignmnet but i have tried really hard
a default constructor to create a Vector,
an addBox method that adds a Box object to the Vector,
a printVector method to print the dimensions of each Box object in the Vector.
public class BoxVector {
//Part A: declare a Vector as a private data field
//Part B: Write a constructor to create a Vector
//Part C: Write a addBox method to add a Box object to the Vector
//Part D: Write a method to print the dimensions of each Box object in the Vector
public static void main(String argv[]){
BoxVector v;
v = new BoxVector();
Box b1 = new Box (1,2,3);
Box b2 = new Box (4,5,6);
v.addBox(b1);
v.addBox(b2);
v.printVector();
}
}
The output of the program should be as follows (assuming you have added the required methods in correctly):
Box 0 dimension:
width = 1.0
height = 2.0
length = 3.0
Box 1 dimension:
width = 4.0
height = 5.0
length = 6.0
here is what i have I am so lost
import java.util.*;
class BoxVector{ public static void main (String[] args) {
Vector bv = new Vector(2); //create a vector with the capacity of 2
System.println("Capacity = “ + bv.capacity() + “ size = “ + bv.size());"
BoxVector bv;
bv = BoxVector();
Box b1 = new Box(1.0, 2.0, 3.0);
Box b2 = new Box();
Box b3 = new Box(0.5, 1.5, 2.5);
bv.add(b1); //add b1 to the end of vector
bv.add(b2); //add b2 to the end of vector
bv.add(b3); //add b3 to the end of vector
System.println ("Capacity = “ + bv.capacity() + “ size = “ + bv.size());"
System.println ("Width of the 1st element = “ + ((Box)bv.firstElement()).getWidth());"
System.println ("Width of the 2nd element = “ + ((Box)bv.elementAt(1)).getWidth());"
System.println ("Width of the last element = “ + ((Box)bv.lastElement()).getWidth());"
bv.remove(2); System.println("Capacity = “ + bv.capacity() + “ size = “ + bv.size());" }}