/** * Stores First and Last Name. * Also Has 2 Methods - constructor and toString(). * And four more methods: set() and get() for each data field. * * @author William McDaniel Albritton */ public class Name2{ /* These Are The Data Fields. Used to STore EACH Object's Data. Syntax: private ClassName variableName; */ private String first; private String last; /** * Constructor - Used To Create EAch Object and Initialize DAta Fields. * * @param firstName is the first name. * @param lastName is the last name. */ public Name2(String firstName, String lastName){ //This Code Initializes The Data Fields. //Syntax: dataField = parameter; first = firstName; last = lastName; } /** * Used to Display The Data Stored In Each Object's Data Field. * * @return a String in format: LastName, FirstName */ public String toString(){ //Create a Local VAriable. String fullName = new String("full name"); //add last name to first name fullName = last + ", " + first; //Return the Local Variable. return fullName; } /** * This Is An "Accessor" Method - Used To Get A Data Field. * * @return the First Name */ public String getFirstName(){ //Return the Data Field. return first; } /** * This Is An "Accessor" Method - Used To Get A Data Field. * * @return the Last Name */ public String getLastName(){ //Return the Data Field. return last; } /** * This Is A "Mutator" Method - Used To Set A Data Field. * * @param firstNameParameter is the first name. */ public void setFirstName(String firstNameParameter){ //SEt the Data Field. first = firstNameParameter; } /** * This Is A "Mutator" Method - Used To Set A Data Field. * * @param lastNameParameter is the last name. */ public void setLastName(String lastNameParameter){ //set the Data Field. last = lastNameParameter; } }//End of Class.