This is what I need to achieve:
The user can try to input a valid license plate. The valid license plate must be in the following format:
[XXXX][YYY]
Where X is a number between 0 and 9 and Y is an alphabet between A and Z. The user can input word ‘random’ (case insensitive). After that, the program will generate a new random valid license plate.
This is my current code:
for (int i = 0; i < 25; i++)
System.out.println("");
String plat = "";
do {
System.out.print("License Plate Format: XXXXYYY ");
plat = scan.nextLine();
for (int i = 0; i < plate.size(); i++) {
if(plat.matches(plate.get(i))) {
System.out.println("not unique!");
scan.nextLine(); plat = " "; break;
}
}
while (plat.length() < 7 );
plate.add(plat);
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…