I want to generate a random number to apply to some arrays in order to get different elements in each execution. The arrays contain names of sport products (product,size,price,etc). By doing this, I want to make random products that would go into a String, but in each execution of the program, I get the same product.
Where is the problem?
Here is the code in the class generaProductos:
public void generaProductos() {
int num;
for (int i=0;i<3;i++){
num = (int) Math.random() * 3;
String cliente = tipoProducto[num] + " " + deporte[num] + " " +
destinatario[num] + " " + color[num] + " " + tallaRopaAdulto[num]
+ " " + preciosIVA[num];
System.out.println(cliente);
}
return;
}
And here is where I call generaProductos()
method in main:
switch (opt){
case 1:
generaProductos alm = new generaProductos();
alm.generaProductos();
When I execute my code, I always receive this:
Botas Futbol Hombre Marron S 16.99
Botas Futbol Hombre Marron S 16.99
Botas Futbol Hombre Marron S 16.99
(In English it would be Football boots men brown size S 16.99)