
ShorterNameGenComplete
By:
ace on
Mar 17th, 2010 | syntax:
None | size: 1.31 KB | hits: 10 | expires: Never
import java.util.ArrayList;
import java.util.HashMap;
/**
* Write a description of class NameGenerator here.
*
* @author Jason
* @version 1.0 3/17/10
/* class contains an array list for each of first names and second names
*
class contains a HashMap for names
*/
public class NameGenerator
{
private HashMap <String, String> nameMap;
/**
* Constructor for objects of class NameGenerator
*/
public NameGenerator()
{
/* creates an array list for first names;
creates an array list for second names;
creates a hash map for star wars names;
*/
nameMap = new HashMap <String, String>();
}
/**
* method to generate first star wars name
*/
public String generateStarWarsName(String firstName, String secondName, String mothersName,
String townName)
{
String firstSWName = secondName.substring(0, 3) + firstName.substring(0,2);
String secondSWName = (mothersName.substring(0,2) + townName.substring(0,3));
String starWarsName = firstSWName + " " + secondSWName;
nameMap.put(firstSWName, starWarsName);
nameMap.put(secondSWName, starWarsName);
return starWarsName;
}
}