fix rare bug with random name

This commit is contained in:
Matti 2024-05-01 20:30:19 +02:00
parent 43484e54f2
commit 79c924b0dc

View File

@ -102,7 +102,7 @@ public class CustomerData {
int index;
while (name == null){
index = Math.toIntExact(Math.round(Math.random() * amountOfNames));
index = Math.toIntExact(Math.round(Math.random() * (amountOfNames-1)));
name = allFirstNames.getData(index);
}
return name;
@ -115,25 +115,15 @@ public class CustomerData {
int index;
while (name == null){
index = Math.toIntExact(Math.round(Math.random() * amountOfNames));
index = Math.toIntExact(Math.round(Math.random() * (amountOfNames-1)));
name = allLastNames.getData(index);
}
return name;
}
public static void main(String[] args){
CustomerData data = new CustomerData();
data.readFirstNames();
System.out.println(Arrays.toString(data.allFirstNames.getAll()));
data.readLastNames();
System.out.println(Arrays.toString(data.allLastNames.getAll()));
data.readStreets();
System.out.println(Arrays.toString(data.allStreets.getAll()));
data.readCities();
System.out.println(Arrays.toString(data.allCitiesNCodes.getAll()));
System.out.print(data.getRandomFirstName() + " " + data.getRandomLastName());
}
}