I have the following classes:
- parent class CandyBox which has arguments private String flavor and private String origin + method getVolume() which return 0
- 3 children classes of CandyBox: A, B and C - which have specific additional arguments like height, radius, width, etc, to compute the volume based on the box form
No, I need to create another class, called CandyBag - the idea of this class is to contain an ArrayList which will be a gift composed of one object from class A, one object from class B and one object from class C.
class CandyBag extends CandyBox{
ArrayList<CandyBox> candybag = new ArrayList<CandyBox>();
and I was thinking of declaring object from class A for example:
CandyBox Austria_cherry = new A(20, 5.4, 19.2);
and then add it to the ArrayList: candybag.add(Austria_cherry);
but I do not think it is a good idea for adding many objects and I also have many errors like expected
I do not know how to structure my code to add these objects from multiple classes in that ArrayList, I am stuck here, can you please help?