I have a class Torres
that is composed of other classes Plaques
and Memories
all inherit from Producto
:
public class Torres extends Producto {
private Plaques plaques;
private Memories memories;
public Torres(String codiIntern, String descripcio, String nomFab, double preuC, double preuBrut, int estoc,Plaques plaques,Memories memories) {
super(codiIntern, descripcio, nomFab, preuC, preuBrut, estoc);
this.memories = memories;
this.plaques = plaques;
}
}
I also have a TreeMap
that represents the components with which the object Torres
will be formed, formed with different Plaques
and Memories
. The key is the codiIntern, and the value is only objects Plaques
and Memories
torres = new TreeMap<String,Producto>();
My question would be how to make a method that creates an object of Torres
with all the elements of the list TreeMap
. If for example there is 2 Plaques
and 1 Memories
should create a Tower that has those 2 Plaques
and 1 Memories
.