How can I send an array with values to another class, go through it (with a for) and validate each index (with an if) to send a message if it is complete or send an error message. It is a method in the class Validations that resiva the object of the main Maybe they are simple or trivial things but I am new in this. I leave my code:
public static void main(String[] args)
{
//AQUI INSTANCIE UN OBJETO DE LA CLASE BANDA
Banda arreglo = new Banda();
Musico[] musico = arreglo.musico;
Instrumento guitarra = new Instrumento("guitarra","cuerdas");
Musico AngusYoung = new Musico("AngusYoung","solista",guitarra);
AngusYoung.setInstrumento(guitarra);
Instrumento voz = new Instrumento("voz","viento");
Musico BrianJohnson = new Musico("BrianJohnson","vocalista",voz);
BrianJohnson.setInstrumento(voz);
Instrumento guitarraritmica = new Instrumento("guitarra ritmica","cuerdas");
Musico MalcolmYoung = new Musico("MalcolmYoung","ritmico",guitarraritmica);
MalcolmYoung.setInstrumento(guitarraritmica);
Instrumento bajo = new Instrumento("bajo","cuerdas");
Musico CliffWilliams = new Musico("CliffWilliams","bajista",bajo);
CliffWilliams.setInstrumento(bajo);
Instrumento bateria = new Instrumento("bateria","percusion");
Musico ChrisSlade = new Musico("ChrisSlade","baterista",bateria); ChrisSlade.setInstrumento(bateria);
musico[0]= AngusYoung;
musico[1]= BrianJohnson;
musico[2]= MalcolmYoung;
musico[3]= CliffWilliams;
musico[4]= ChrisSlade;
}
public class Banda {
Musico musico[] = new Musico[5]; //ARREGLO
public Banda() {
}
public Musico[] getMusico() {
return musico;
}
public void setMusico(Musico[] musico) {
this.musico = musico;
}
public String toString() {
return "Banda{" + "musico=" + musico + '}';
}
public class Validaciones { //EN ESTA CLASE DEBO MANDAR A LLAMAR EL ARREGLO QUE SE LLENO EN EL MAIN
//SUPUESTO METODO QUE RESIVE EL ARREGLO LLENO DEL MAIN
public Musico band (Musico[] musico){
//CREO QUE SE DEBE ASIGNAR A UNA VARIABLE PARA USARLO
//AQUI DEBERIA ESTAR EL IF Y EL FOR
return null;
}
}
I have researched but it is not clear to me how to handle an array as an object in a method.