package Demo1PersonClass;
/**
* @author Dr. Kevin Roark
* Class contains attributes and methods for a Person
*/
public class Person {
/* -----------------------------------
* Class Variables
----------------------------------- */
private String firstName;
private String lastName;
private int age;
/*
* Constructors
----------------------------------- */
public Person(String firstName, String lastName, int age) {
super();
this.firstName = firstName;
this.lastName = lastName;
this.age = age;
}
public Person() {
super();
this.firstName = "Unknown FirstName";
this.lastName = "Unknown LastName";
this.age = -1;
}
/* -----------------------------------
* Getter/Setters
----------------------------------- */
public String getFirstName() {
return firstName;
}
public void setFirstName(String firstName) {
this.firstName = firstName;
}
public String getLastName() {
return lastName;
}
public void setLastName(String lastName) {
this.lastName = lastName;
}
public int getAge() {
return age;
}
public void setAge(int age) {
this.age = age;
}
/* -----------------------------------
* Class Methods
----------------------------------- */
/**
* Function creates a string with labels and Object data
* @return String
*/
public String PrintInfo()
{
String myReturn = "";
myReturn = "Name: " + this.getFirstName() + " " + this.getLastName() + "\n";
myReturn += "Age: " + this.getAge();
return myReturn;
}
}
|