fix rare bug with random name
This commit is contained in:
parent
43484e54f2
commit
79c924b0dc
@ -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());
|
||||
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user