cookercucumber_parser.fileGenerationFactory.RandomNumberGenerator Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of cooker-maven-plugin Show documentation
Show all versions of cooker-maven-plugin Show documentation
Derives smallest Feature File, Allows Data from Excel(xls and xlsx) and Also provides a clear and
concise reporting
package cookercucumber_parser.fileGenerationFactory;
public class RandomNumberGenerator {
/**
* This method is used to get the random number between AA to ZZ and 0001 to 9999 (XX8888)
* Author : Manjunath Prabhakar ([email protected])
*
* @return : formatted random number
*/
public static String genRandomNumber() {
int minNum = 1, maxNum = 9999;
int random = (int) (Math.random() * maxNum + minNum);
String formattedRandomNum = String.format("%04d", random);
final String ALPHA = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
int alpharandom1 = (int) (Math.random() * 25 + 0);
int alpharandom2 = (int) (Math.random() * 25 + 0);
String res = "" + ALPHA.charAt(alpharandom1) + ALPHA.charAt(alpharandom2) + formattedRandomNum;
return res;
}
}