Assuming five vowels (that is considering '
Y
' a consonant), you could have
10 ^ 3 * 21 ^ 3 * 9 = 83349000
different plates.
So you can choose a random number in the
[0..83348999]
range and generate the plate string using it. I am going to show you the code:
import java.util.Random;
class Plate
{
static final int PLATES = 83349000;
static String plate(int n)
{
char [] dgt = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9' };
char [] letter = { 'B', 'C', 'D', 'F', 'G', 'H', 'J', 'K', 'L', 'M', 'N', 'P', 'Q', 'R', 'S', 'T', 'V', 'W', 'X', 'Y', 'Z' };
String [] cc = { "CA", "ZN", "MP", "EC", "L", "GP", "NC", "FS", "NW" };
String p = "";
if ( n<0 || n >= PLATES) return p;
int rem;
for ( int i = 0; i<3; i++)
{
rem = n % 10;
p += dgt[rem];
n = (n - rem) / 10;
}
p += "-";
for ( int i = 0; i<3; i++)
{
rem = n % 21;
p += letter[rem];
n = (n - rem) / 21;
}
p += "-";
rem = n % 9;
p += cc[rem];
return p;
}
public static void main(String arg[])
{
int n;
Random rand = new Random();
for (n=0; n<10; ++n)
{
int r = rand.nextInt(PLATES);
System.out.printf( "%3d %s\n", (n+1), plate( r) );
}
}
}
Now you have to generate 1000000 of such plates (and I assume) avoiding repetitions.
You could use (if your programming box has enough memory) the algorithm shown here:
Random extraction of 5 cards from a deck[
^] to make the trick.
Finally you have to create a
GUI
for it, possibly using, as suggested the Swing Framework. This artistic step is very up to you.