/** * Contains information about a person's name. * @author Khong Lovan * @author Elias Vafiadis * @author Anthony Nakaar * @author Wanlin Liu * version 1.0 of October, 1999 */ public class Name { //+--------+---------------------------------------------------------- //| Fields | //+--------+ /* First name.*/ String firstName; /* Last name. */ String lastName; /* Middle name. */ String middleName; /* Suffix.*/ String suffix; //+--------------+-------------------------------------------------------- //| Constructors | //+--------------+ /** * Purpose: create a new instance of class Name. * Parameter: two strings, last name and first name. * Pre: none. * Post: the new object has the given last name as the value of lastName * and the given first name as the value of firstName. * Return: none. * throws no exceptions. */ public Name(String firstN, String lastN) { firstName = firstN; lastName = lastN; } /** A constructor that takes firstname, middle name, and the last name*/ public Name(String firstN, String middleN, String lastN) { firstName = firstN; middleName = middleN; lastName = lastN; } /** A constructor taking 4 parameters, first anme, middle name, * last name and the suffix. */ public Name(String firstN, String middleN, String lastN, String suf) { firstName = firstN; middleName = middleN; lastName = lastN; suffix = suf; } //+------------+--------------------------------------------------------- //| Extractors | //+------------+ /** * Purpose: get the value of firstName * Paramter: none * Pre: none. * Post: the value of firstName is not changed. * Return: the value of the firstName, a string. * throws no exceptions */ public String getFirstName() { return this.firstName; }//getFirstName() /** * Purpose: get the value of middleName * Paramter: none * Pre: middleName has been initialized. * Post: the value of middleName is not changed. * Return: the value of the middleName, a string. * @exception nameException * if middleName is not initialized. */ public String getMiddleName() { return this.middleName; }//getMiddleName() /** * Purpose: get the value of lastName * Paramter: none * Pre: none. * Post: the value of lastName is not changed. * Return: the value of the lastName, a string. * throws no exceptions */ public String getLastName() { return this.lastName; }//getLastName() /** * Purpose: get the value of Suffix. * Paramter: none * Pre: Suffix has been initialized. * Post: the value of Suffix is not changed. * Return: the value of the Suffix, a string. * @exception nameException * if Suffix is not initialized. */ public String getSuffix() throws NameException { return this.suffix; }//getSuffix() //+-----------+-------------------------------------------------------- //| Modifiers | //+-----------+ /** * Purpose: change the value of firstName * Paramter: the new first name, a string. * Pre: none. * Post: the value of firstName is changed into the new value. * Return: none * throws no exceptions. */ public void setFirstName(String firstN) { this.firstName = firstN; }//setFirstName() /** * Purpose: change the value of middleName * Paramter: the new middle name, a string. * Pre: none. * Post: the value of middleName is changed into the new value. * Return: none * throws no exceptions. */ public void setMiddleName(String middleN) throws NameException { this.middleName = middleN; }//setMiddleName() /** * Purpose: change the value of lastName * Paramter: the new last name, a string. * Pre: none. * Post: the value of lastName is changed into the new value. * Return: none * throws no exceptions. */ public void setLastName(String lastN) { this.lastName = lastN; }//setLastName() /** * Purpose: change the value of Suffix. * Paramter: the new suffix, a string. * Pre: none. * Post: the value of suffix is changed into the new value. * Return: none * throws no exceptions. */ public void setSuffix(String newSuffix) { this.suffix = newSuffix; }//setSuffix() //+--------------+-------------------------------------------------- //| Capabilities | //+--------------+ /** * Purpose: convert the contents of the object to a displayable string. * Paramter: none. * Pre: all the fields of the objects are initialized. * Post: no value is changed. * Return: a string containing all values of fields of this object. * Throws no exceptions. */ public String toString() { return "Sam Rebelsky."; }//toString() }