Good you could help me to make a method that returns an object of so much Magazine / Novels of class Daughter being the arrangement of the inventory of type Books as a parent class, I need in the main program the object of the type of the class to be able use their attributes.
public Inventario () {
ind=0;
max=100;
Almacen=new Libros[100];
}
public String almacenarProducto(Revistas c){
if(ind<max){
Almacen[ind++]=c;
return "El producto se agregó correctamente";
}
return "Inventario lleno";
}
public String almacenarProducto(Novelas c){
if(ind<max){
Almacen[ind++]=c;
return "El producto se agregó correctamente";
}
return "Inventario lleno";
}
public Libros buscarLibro(String c){
Revistas nulo = new Revistas("Desconocido", 0, "Desconocido","Desconocido","Desconocido",
"Desconocido","Desconocido");
if(ind!=0){ //ind solo es 0 cuando no hay nada en el Arreglo
for(int i=0 ;i<ind;i++){
if(c.compareTo(Almacen[i].getNombre(Almacen[i]) )==0) {
System.out.println(Almacen[i].mostrarProducto());
return Almacen[i];
}
}
System.out.println("No se encuentra el libro que
solicito, intente con otro nombre.");
return nulo;
}
else
System.out.println("No hay productos en el inventario");
return nulo;
}