package utils; import java.util.UUID; /** * Class to enforce the game rule * of generating unique names * * @author Jason Agurkis * @author Jacob Drecksage * */ public class NameGenerator { // private final static String _PLAYER_FLAG = "JJ"; //marker for derivatives created by this player /** * generate a new name and return the string * * @return string */ public static String getNewName(String name) { UUID newID = UUID.randomUUID(); //generate a new UUID String uuidString = newID.toString(); //convert the UUID to a String char oldChar = '-'; //the hyphen character is not legal in the class dictionary char newChar = '_'; //the hyphens are therefore replaced with an _. uuidString = uuidString.replace(oldChar, newChar); String retName = name+"_".concat( uuidString ); //combine our branding and uuid return retName; //return the resulting String } }