FileDocCategorySizeDatePackage
Person.javaAPI DocExample884Tue Oct 22 21:03:22 BST 2002com.oreilly.javaxp.junit

Person.java

package com.oreilly.javaxp.junit;

/**
 * @author Eric M. Burke
 * @version $Id: Person.java,v 1.1 2002/10/23 02:03:22 jepc Exp $
 */
public class Person {
    private String firstName;
    private String lastName;

    public Person(String firstName, String lastName) {
        if (firstName == null && lastName == null) {
            throw new IllegalArgumentException("Both names cannot be null");
        }
        this.firstName = firstName;
        this.lastName = lastName;
    }

    public String getFullName() {
        String first = (this.firstName != null) ? this.firstName : "?";
        String last = (this.lastName != null) ? this.lastName : "?";

        return first + " " + last;
    }

    public String getFirstName() {
        return this.firstName;
    }

    public String getLastName() {
        return this.lastName;
    }
}