<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">/**
 * A person has a first and last name.
 */
public class Person {
  private String firstName;
  private String lastName;

  public static String sep = " ";

  /**
   * Create a person with the given first and last names.
   * Precondition: neither first nor last contain the ' ' character.
   */
  public Person(String firstName, String lastName) {
    assert !firstName.contains(sep);
    assert !lastName.contains(sep);

    this.firstName= firstName;
    this.lastName= lastName;
  }

  /**
   * Create a person with the given full name.
   */
  public Person(String fullName) {
    // Calling this() invokes the constructor above. The call to
    // this() must be the first statement in the constructor.
    this(fullName.split(sep)[0], fullName.split(sep)[1]);
  }

  /**
   * Get the person's full name.
   */
  public String getName() {
    return firstName + sep + lastName;
  }

  /**
   * Get the person's last name.
   */
  public String getLastName() {
    return lastName;
  }
}
</pre></body></html>