001package edu.pdx.cs410J.family;
002
003import java.text.DateFormat;
004import java.text.ParseException;
005
006/**
007 * A class with a main method for testing {@link Person}.  Once upon a time,
008 * this functionality was part of the <code>Person</code> class.
009 *
010 * @since Summer 2008 
011 */
012public class PersonMain {
013  /**
014   * A simple test program.
015   */
016  public static void main(String[] args) {
017    // Make some people and fill in information
018    Person me = me();
019    Person dad = dad(me);
020    Person mom = mom(me);
021
022    me.setMother(mom);
023    me.setFather(dad);
024
025    // Print out descriptions of these people
026    System.out.println(me + "\n");
027    System.out.println(mom + "\n");
028    System.out.println(dad + "\n");
029
030  }
031
032  /**
033   * Returns a Person representing me.
034   */
035  static Person me() {
036    Person me = new Person(1, Person.MALE);
037    me.setFirstName("David");
038    me.setMiddleName("Michael");
039    me.setLastName("Whitlock");
040
041    return me;
042  }
043
044  /**
045   * Returns a Person representing my mom.
046   */
047  static Person mom(Person me) {
048    Person mom = new Person(2, Person.FEMALE);
049    mom.setFirstName("Carolyn");
050    mom.setMiddleName("Joyce");
051    mom.setLastName("Granger");
052
053    try {
054      DateFormat df = DateFormat.getDateInstance(DateFormat.MEDIUM);
055      mom.setDateOfBirth(df.parse("May 17, 1945"));
056
057    } catch (ParseException ex) {
058      System.err.println("** Malformatted mom's birthday?");
059      System.exit(1);
060    }
061
062    return mom;
063  }
064
065  /**
066   * Returns a Person representing my dad.
067   */
068  static Person dad(Person me) {
069    Person dad = new Person(3, Person.MALE);
070    dad.setFirstName("Stanley");
071    dad.setMiddleName("Jay");
072    dad.setLastName("Whitlock");
073
074    try {
075      DateFormat df = DateFormat.getDateInstance(DateFormat.MEDIUM);
076      dad.setDateOfBirth(df.parse("Feb 27, 1948"));
077
078    } catch (ParseException ex) {
079      System.err.println("** Malformatted dad's birthday?");
080      System.exit(1);
081    }
082
083    return dad;
084  }
085}