J'ai vu quelqu'un essayé de faire un générateur de code (sous vb.net) mais on lui a reproché que ça n'était paq aléatoire donc je vous propose un generateur de code sous modèle (Pourquoi sous modèle car vous choisissez la ou il y a des lettres et la ou il y a des chiffres ):
(Pour mettre un aléatoire de caractère : randomChar () et un aléatoire de nombre : rand.nextInt(9)
import java.util.*;
public class Main
{
public static void main(String[] args){
Random rand = new Random();
//Premiere serie de chiffre/lettre
int a1 = rand.nextInt(9);
char a2 = randomChar();
char a3 = randomChar();
int a4 = rand.nextInt(9);
//deuxieme serie de chiffre/lettre
int b1 = rand.nextInt(9);
char b2 = randomChar();
int b3 = rand.nextInt(9);
int b4 = rand.nextInt(9);
//Troisieme serie de chiffre/lettre
int c1 = rand.nextInt(9);
int c2 = rand.nextInt(9);
int c3 = rand.nextInt(9);
int c4 = rand.nextInt(9);
//Quatrieme serie de chiffre/lettre
char d1 = randomChar();
char d2 = randomChar();
int d3 = rand.nextInt(9);
char d4 = randomChar();
System.out.println(a1+ "" + a2 + "" + a3 + "" + a4 + "-" + b1 + "" + b2 + "" + b3 + "" + b4 + "-" + c1 + "" + c2 + "" + c3 + "" + c4 + "-" + d1 + "" + d2 + "" + d3 + "" + d4);
}
public static char randomChar(){
char cha ;
Random rand = new Random();
cha = (char)(rand.nextInt(26) + 'A');
return cha ;
}
}