Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class NameGenerator
- {
- private static final String[] first = {"Sour","Strawberry","Train","Blue","Mage" , randomName(), randomName()};
- private static final String[] last = {"Diseal","Cough","Wreck","Berry", randomName() ,randomName() };
- private static ArrayList<String> copies = new ArrayList();
- private static String randomName()
- {
- Random rand = new Random();
- String name = "";
- String aplh = "abcdefghijklmnopqrstuvwxyz";
- for(int i = 0 ; i < rand.nextInt(5); i++)
- {
- name += aplh.charAt(rand.nextInt(26));
- }
- return name;
- }
- public static String generateName(int minLength)
- {
- Random rand = new Random();
- String name = first[rand.nextInt(first.length)] + last[rand.nextInt(last.length)] + rand.nextInt(99);
- while(name.length() < minLength && !copies.contains(name))
- {
- name += getChar();
- }
- copies.add(name);
- return name;
- }
- private static char getChar()
- {
- String rands = "abcdefghijklmnopqrstuvwxwyz1230478598aaeeiioo";
- Random rand = new Random();
- return rands.charAt(rand.nextInt(rands.length()));
- }
- public static String generateName()
- {
- return generateName(8);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement