forked from MLSA-Mehran-UET/Learn-to-code-java
- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBarcodeGenerator.java
More file actions
Latest commit
27 lines (24 loc) · 846 Bytes
/
Copy pathBarcodeGenerator.java
File metadata and controls
27 lines (24 loc) · 846 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
/*
*/
importjava.util.Random; // make sure to write the import for Random class
/**
*
* @author ahsan
*/
publicclassBarcodeGenerator
{
publicStringgenerateBarcode()
{
Stringbarcode;
String[] numbers={"0","1","2","3","4","5","6","7","8","9"};
String[] Alphabets ={"A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"};
Randomrandom = newRandom(); //creating instance of Random class
intn1=random.nextInt(10); // generating a random number
intn2=random.nextInt(10);
intn3=random.nextInt(10);
intn4=random.nextInt(10);
// now creating barcode using random numbers i-e n1, n2
barcode= numbers[n1]+numbers[n2]+numbers[n3]+numbers[n4];
returnbarcode;
}
}