/* Person.java Author: Cameron D. Bunch Date: 22 July 2009 Description: The Person class represents one individual person. It manages the following data about a person: Last name Middle initial First name Age Weight It additionally generates a calculated string containing the person's full name. */ public class Person { // Instance variables private String firstName; private String middleInitial; private String lastName; private int age; private double weight; // Default constructor public Person() { } // Constructor that loads the names into the new object public Person( String fName, String mInitial, String lName ) { firstName = fName; middleInitial = mInitial; lastName = lName; } // String getFullName() // // Returns the calculated full name in the following format: // // Last, First M. // public String getFullName() { return lastName + ", " + firstName + " " + middleInitial + "."; } // Getters. public String getFirstName() { return firstName; } public String getMiddleInitial() { return middleInitial; } public String getLastName() { return lastName; } public int getAge() { return age; } public double getWeight() { return weight; } // Setters. public void setFirstName( String newFirstName ) { firstName = newFirstName; } public void setMiddleInitial( String newMiddleInitial ) { middleInitial = newMiddleInitial; } public void setLastName( String newLastName ) { lastName = newLastName; } public void setAge( int newAge ) { if( newAge < 0 || newAge > 110 ) age = -1; else age = newAge; } public void setWeight( double newWeight ) { weight = newWeight; } }