I have being stuck with this assignment for weeks now. I just need some help for starting. Here is first requriment:
Design a generic container called GenericOrder that acts as a collection of an arbitrary number of objects in Products.java. Design a mechanism that gives each instance of the container a unique identifier. Implement as many methods as necessary. You must use Java generics features.
Here is what I have, I don't if I did right or not. The instructor says, this GenericOrder must use collection to hold multiple "Product".
public class GenericOrder<T> {
private T theProduct;
private static int count = 1;
private final int orderNumber = count++;
private Collection<T> genCollection;
public GenericOrder(T theClass)
{
this.theProduct = theClass;
}
public String getProductID()
{
return theProduct.getClass().getName() + ": " + orderNumber;
}
public T createInstance()
throws IllegalAccessException, InstantiationException {
return this.theProduct;
}
}
classsatisfies the assignment?