I have a base class Product that has five subclasses (ComputerPart, Peripheral, Service, Cheese, Fruit). Each of these further have 2/3 subclasses.
Then I have a GenericOrder
class that acts as a collection of an arbitrary number of objects in the Product class. GenericOrder
has a subclass called ComputerOrder
that will only allow ComputerPart
, Peripheral
and Service
to be added to the order. I've spent quite some time trying to figure this out but couldn't get a reasonable answer. Please help. Here's what I have for GenericOrder
:
public class GenericOrder<T>{
private static long counter=1;
private final long orderID = counter++;
private List<T> orderItems;
public GenericOrder(){
orderItems = new ArrayList<T>();
}
// and so on with another constructor and add, get and set methods.
}
class ComputerOrder<T> extends GenericOrder{
//need help here
}
Any any will be greatly appreciated.....
Cheers