-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathamsFlightCode.java
44 lines (31 loc) · 1.11 KB
/
amsFlightCode.java
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
package amsSystem;
import java.util.Random;
public class amsFlightCode{
//Code used to generate specific flight codes for the company
private String flightCode;
private static final String characters = "ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890!@#$%^&*"; //All characters that can be used
public amsFlightCode(){
this.flightCode = "";
}
public amsFlightCode(String flightCode){
this.flightCode = flightCode;
}
public String getFlightCode() {
return flightCode;
}
public void setFlightCode(String flightCode) {
this.flightCode = flightCode;
}
public String createFlightCode(){ //Creating Flight Code randomly for each flights
Random code = new Random();
int codeLength = 10;
StringBuilder code2 = new StringBuilder(codeLength);
for(int i = 0; i < codeLength; i++){
int randomIndex = code.nextInt(characters.length());
char randomChar = characters.charAt(randomIndex);
code2.append(randomChar);
}
flightCode = code2.toString();
return flightCode;
}
}