|
import java.io.File; |
|
import java.io.FileNotFoundException; |
|
import java.util.ArrayList; |
|
import java.util.Random; |
|
import java.util.Scanner; |
|
|
|
public class EmailGenerator { |
|
|
|
ArrayList<String> nomes; |
|
ArrayList<String> apelidos; |
|
ArrayList<String> nicknames; |
|
Random random; |
|
|
|
public EmailGenerator(ArrayList<String> nomes, ArrayList<String> apelidos, ArrayList<String> nicknames) { |
|
this.nomes = nomes; |
|
this.apelidos = apelidos; |
|
this.nicknames = nicknames; |
|
random = new Random(); |
|
} |
|
|
|
public String generate() { |
|
|
|
if (random.nextInt(4) == 0) |
|
return generateNickname(); |
|
else |
|
return generateName(); |
|
} |
|
|
|
private String generateName() { |
|
|
|
// Adicionar o nome |
|
int n = random.nextInt(nomes.size()); |
|
String result = nomes.get(n); |
|
|
|
// Adicionar o numero e acabar |
|
if (random.nextInt(5) == 0) |
|
return result + generateNumber() + generateEmail(); |
|
|
|
// Adicionar coisas entre o nome e o apelido |
|
n = random.nextInt(12); |
|
if (n > 10) |
|
result += generateNumber(); |
|
else if (n > 8) |
|
result += '-'; |
|
else if (n > 4) |
|
result += '_'; |
|
|
|
// Adicionar o apelido |
|
n = random.nextInt(apelidos.size()); |
|
result += apelidos.get(n); |
|
|
|
// Adicionar numero no fim |
|
if (random.nextInt(3) > 0) |
|
result += generateNumber(); |
|
|
|
return result + generateEmail(); |
|
} |
|
|
|
private String generateNickname() { |
|
|
|
int n = random.nextInt(nicknames.size()); |
|
String result = nicknames.get(n); |
|
|
|
if (random.nextInt(3) == 0) |
|
result += generateNumber(); |
|
|
|
return result + generateEmail(); |
|
} |
|
|
|
private String generateNumber() { |
|
return Integer.toString(random.nextInt(100)); |
|
} |
|
|
|
private String generateEmail() { |
|
int n = random.nextInt(5); |
|
|
|
if (n == 0) |
|
return "@live.com.pt"; |
|
else if (n == 1) |
|
return "@hotmail.com"; |
|
else |
|
return "@gmail.com"; |
|
} |
|
|
|
// ----- STATIC ZONE ----- |
|
|
|
public static ArrayList<String> readFile(String fileName) throws FileNotFoundException { |
|
File file = new File(fileName); |
|
Scanner input = new Scanner(file); |
|
|
|
ArrayList<String> result = new ArrayList<>(); |
|
|
|
while (input.hasNextLine()) |
|
result.add(input.nextLine()); |
|
|
|
input.close(); |
|
return result; |
|
} |
|
|
|
public static void main(String args[]) throws FileNotFoundException { |
|
|
|
ArrayList<String> nomes = readFile("//home//cyrillbrito//Dropbox//Projects//VotingBot//lista_nomes"); |
|
ArrayList<String> apelidos = readFile("//home//cyrillbrito//Dropbox//Projects//VotingBot//lista_apelidos"); |
|
ArrayList<String> nicknames = readFile("//home//cyrillbrito//Dropbox//Projects//VotingBot//lista_nicknames"); |
|
|
|
EmailGenerator gen = new EmailGenerator(nomes, apelidos, nicknames); |
|
|
|
ArrayList<String> emails = new ArrayList<>(); |
|
|
|
for (int i = 0; i < 10000; i++) { |
|
String email = gen.generate(); |
|
if (!emails.contains(email)) |
|
emails.add(email); |
|
} |
|
|
|
for (String email : emails) |
|
System.out.println(email); |
|
} |
|
} |