Pastebin launched a little side project called HostCabi.net, check it out ;-)Don't like ads? PRO users don't see any ads ;-)
Guest

starwarsgenerator3

By: ace on Mar 17th, 2010  |  syntax: None  |  size: 1.87 KB  |  hits: 11  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
This paste has a previous version, view the difference. Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. import java.util.ArrayList;
  2. import java.util.HashMap;
  3. /**
  4.  * Write a description of class NameGenerator here.
  5.  *
  6.  * @author Jason
  7.  * @version 1.0 3/17/10
  8.  
  9.     /* class contains an array list for each of first names and second names
  10.      *
  11.      class contains a HashMap for names
  12.      */
  13.     public class NameGenerator
  14.     {
  15.          
  16.     private ArrayList <String> firstNameList;
  17.     private ArrayList <String> secondNameList;
  18.     private HashMap <String, String> nameMap;
  19.     private String firstSWName;
  20.     private String secondSWName;
  21.     private String starWarsName;
  22.     private String starWarsFirstName ;
  23.     private String starWarsSecondName;
  24.  
  25.  
  26.  
  27.     /**
  28.      * Constructor for objects of class NameGenerator
  29.      */
  30.     public NameGenerator()
  31.     {
  32.         /* creates an array list for first names;
  33.          creates an array list for second names;      
  34.          creates a hash map for star wars names;
  35.         */
  36.         firstNameList = new ArrayList <String>();
  37.         secondNameList = new ArrayList <String>();
  38.         nameMap = new HashMap <String, String>();
  39.        
  40.     }
  41.  
  42.     /**
  43.      * method to generate first star wars name
  44.      */
  45.     public String generateStarWarsName(String firstName, String secondName, String mothersName,
  46.     String townName)
  47.     {
  48.        
  49.         String firstSWName = secondName.substring(0, 3);
  50.         String secondSWName = firstName.substring(0,2);
  51.         //String thirdSWName = mothersName.substring(0,2);
  52.         //String fourthSWName = townName.substring(0,3);
  53.         firstNameList.add(firstName);
  54.         secondNameList.add(secondName);
  55.         starWarsFirstName = (firstSWName + secondSWName);
  56.         starWarsSecondName = (mothersName.substring(0,2) + townName.substring(0,3));
  57.         starWarsName = starWarsFirstName + " " + starWarsSecondName;
  58.         return starWarsName;      
  59.        
  60.     }
  61. }