title: Creating a small database using variables for constructor names
body: <p>I am trying to create an application that will let you </p>
  
  <p>1 - add  people to a small database</p>
  
  <p>2 - append their name onto an array</p>
  
  <p>3 - when retrieving information previously entered, the array will be used to select the person</p>
  
  <p>4 - retrieve unique information of the person selected</p>
  
  <p>I have two classes, Person(), which is supposed to construct a new person with the given variables and store that information for reading later, and PeopleManager().</p>
  
  <p>Person class:</p>
  
  <pre><code>public class Person extends Object 
  { 
  private static int theNumPersons = 0; // initialize num 
  private String itsFirstName; 
  private String itsLastName; 
  private int itsBirthYear; 
  
  public Person (String first, String last, int year) 
  { 
      super(); 
      theNumPersons++; // update num 
      itsFirstName = first; 
      itsLastName = last; // initialize last name 
      itsBirthYear = year; 
  }
  
  /** Tell how many different Persons exist. */ 
  
  public static int getNumPersons() // access num 
  { 
      return theNumPersons; 
  } 
  
  /** Return the birth year. */ 
  
  public int getBirthYear() 
  { 
      return itsBirthYear; 
  }
  
  /** Return the first name. */ 
  
  public String getFirstName() 
  { 
      return itsFirstName; 
  }
  
  /** Return the last name. */ 
  
  public String getLastName() // access last name 
  { 
      return itsLastName; 
  }
  
  /** Replace the last name by the specified value. */ 
  
  public void setLastName (String name) // update last name 
  { 
      itsLastName = name; 
  }
  }
  </code></pre>
  
  <p>PeopleManager class:</p>
  
  <pre><code>import java.util.*;
  import javax.swing.*;
  
  public class PeopleManager
  {
  static ArrayList names = new ArrayList();
  static int selection;
  
  public static void main()
  {
      askSelection();
  }
  
  public static void askSelection()
  {
      Object[] options = { "Add to Database", "Retrieve Info" };
      selection = JOptionPane.showOptionDialog(null, "What would you like to do?", "People Database Application", JOptionPane.DEFAULT_OPTION, JOptionPane.QUESTION_MESSAGE, null, options, options[0]);
      executeSelection();
  }
  
  public static void executeSelection()
  {
      if (selection == 0)
      {
          addPerson();
          askSelection();
      }
  
      if (selection == 1)
      {
          Object[] nameArray = names.toArray();
          Object person = JOptionPane.showInputDialog(null, "Select person to grab info from.", "People Database Application", JOptionPane.DEFAULT_OPTION, null, nameArray, nameArray[0]);
          getInfo(person);
          askSelection();
      }
  }
  
  public static void addPerson()
  {
          String newFirst = JOptionPane.showInputDialog (null, "Enter the first name.", "John");
          String newLast = JOptionPane.showInputDialog (null, "Enter the last name.", "Doe");
          String sNewYear = JOptionPane.showInputDialog (null, "Enter that person's birth year.", "1965");
          String newFullName = (newFirst + " " + newLast);
  
          int iNewYear = Integer.parseInt(sNewYear);
  
          names.add(newFullName);
          Person newFullName = new Person (newFirst, newLast, iNewYear);
  
  
          JOptionPane.showMessageDialog (null, "Person successfully added.");
      }
  
  public static void getInfo(Object p)
  {
      String infoFirst = p.getFirstName;
      String infoLast = p.getLastName;
      String infoYear = p.getBirthYear;
      String databaseSize = getNumPersons();
  
      JOptionPane.showMessageDialog(null, "First Name: " + infoFirst + "\nLast Name: " + infoLast + "\nBirth Year: " + infoYear + "\n\nTotal people in database: " + databaseSize);
  }
  }
  </code></pre>
  
  <p>I know I'm not doing something right, and I'm pretty sure it has to do with the way I tried to make a new Person() by using a variable.  The problem is, if I can't use a variable to make a new Person(), how can I give the stats to the application user that is specific to the person they entered in?</p>