fix ArrayIndexOutOfBoundsException
This commit is contained in:
@ -1299,21 +1299,25 @@ public class MainWindowController {
|
||||
}
|
||||
|
||||
private static String createJobDescription(String pNames, String pQuantities) {
|
||||
String line = pQuantities;
|
||||
int size = line.length() - line.replace(";", "").length() + 1;
|
||||
// Split the strings
|
||||
String[] namesArray = pNames.split(";");
|
||||
String[] quantitiesArray = pQuantities.split(";");
|
||||
|
||||
String[] namesArray = new String[size];
|
||||
String[] quantitiesArray = new String[size];
|
||||
// Use the minimum length to avoid index out of bounds
|
||||
int minLength = Math.min(namesArray.length, quantitiesArray.length);
|
||||
|
||||
namesArray = pNames.split(";");
|
||||
quantitiesArray = pQuantities.split(";");
|
||||
|
||||
String tmp = quantitiesArray[0] + "x " + namesArray[0];
|
||||
|
||||
for (int i = 1; i < namesArray.length; i++) {
|
||||
tmp = tmp + ", " + quantitiesArray[i] + "x " + namesArray[i];
|
||||
if (minLength == 0) {
|
||||
return ""; // Handle empty input
|
||||
}
|
||||
return tmp;
|
||||
|
||||
// Build the description
|
||||
StringBuilder tmp = new StringBuilder(quantitiesArray[0] + "x " + namesArray[0]);
|
||||
|
||||
for (int i = 1; i < minLength; i++) {
|
||||
tmp.append(", ").append(quantitiesArray[i]).append("x ").append(namesArray[i]);
|
||||
}
|
||||
|
||||
return tmp.toString();
|
||||
}
|
||||
|
||||
private void setJobPrizeLabel(float pPrize) {
|
||||
|
||||
Reference in New Issue
Block a user