1
Chromosome chromosome = new Chromosome();
int[] gene = new int[6];
gene[0] = 0;
gene[1] = (int) (1 + (Math.random() * 3));
gene[2] = (int) (4 + (Math.random() * 4));
gene[3] = (int) (8 + (Math.random() * 4));
gene[4] = (int) (12 + (Math.random() * 3));
gene[5] = 15;
chromosome.setGenes(gene);
return chromosome;
}
I have this method that inserts random numbers, and with that, I need to do another method that calculates the total distance travelled, which would be the 6 positions of the array. But I’m having trouble seeing a way to add that distance in another method.
You want to add up all the indices of that array, that’s it?
– user28595
That’s right, but I don’t know how to have those numbers in another method
– Emily