generateSKU static method
Implementation
static String generateSKU() {
// Define the length of each segment and the total length of the SKU
int segmentLength = 5;
int totalLength = 20;
// Generate random alphanumeric characters for the SKU
String characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
Random random = Random();
String randomSKU = '';
for (int i = 0; i < totalLength; i++) {
if (i > 0 && i % segmentLength == 0) {
randomSKU += '-';
}
randomSKU += characters[random.nextInt(characters.length)];
}
return randomSKU;
}