I have class Vetor
which will have a method to start a vector with random numbers:
public class Vetor{
private int tamanho;
private int[] vetor;
public Vetor(int tamanho) {
this.tamanho = tamanho;
this.vetor = vetor;
}
public void iniciaVetor() {
for (int i = 0; i < tamanho; i++) {
this.vetor[i] = (int) Math.random();
}
}
}
Now I have the class Arraylist
that will have a method to behave an array of vectors:
public class Arraylist{
private int tamanho;
private ArrayList<Vetor> arraylist;
public Arraylist(int tamanho) {
this.tamanho = tamanho;
this.arraylist = new ArrayList<>();
}
public void iniciaArray(int tamanho_vetor) {
Vetor v;
for (int i = 0; i < tamanho_vetor; i++) {
v = new Vetor(tamanho_vetor);
v.iniciaVetor();
arraylist.add(v);
}
}
}
Finally, I have the class select that has a method that will randomly select an index (a vector from the list of vectors) and will fill that vector in the temp
list. It will finish until the temp
is the same size as arraylist
.
public class Selecao{
public ArrayList<Vetor> seleciona(ArrayList<Vetor> arraylist, tamanho_vetor) {
ArrayList temp = new ArrayList<>();
while (arraylist.size() != temp.size()) {
int numero_aleatorio = (int) Math.random();
//cromo adicionar o vetor da posição "numero_aleatorio" no arraylist temp
}
}
}