Access Millions of academic & study documents

Create a person class containing the following state and behavior as

Content type
User Generated
Showing Page:
1/4
Create a person class containing the following state and
behavior as identified below. In addition, the program
should implement a getOldestPerson () method that
returns the full name of the oldest person. You must also
create a personTest class to store atleast five person and
return the older person from the list
Solution
package new2;
public class Person {
private String Firstname;
private String Lastname;
private String Gender;
private int Age;
public Person(String Firstname, String Lastname, String
Gender, int Age) {
this.Firstname = Firstname;
this.Lastname = Lastname;
this.Gender = Gender;
this.Age = Age;
}
public String getFirstname() {
return Firstname;

Sign up to view the full document!

lock_open Sign Up
Showing Page:
2/4
}
public void setFirstname(String Firstname) {
this.Firstname = Firstname;
}
public String getLastname() {
return Lastname;
}
public void setLastname(String Lastname) {
this.Lastname = Lastname;
}
public String getGender() {
return Gender;
}
public void setGender(String Gender) {
this.Gender = Gender;
}
public int getAge() {
return Age;
}
public void setAge(int Age) {
this.Age = Age;
}
public String getOldestPerson(Person p[]) {
int max = 0;
for (int i = 0; i < p.length - 1; i++) {

Sign up to view the full document!

lock_open Sign Up
Showing Page:
3/4

Sign up to view the full document!

lock_open Sign Up
End of Preview - Want to read all 4 pages?
Access Now
Unformatted Attachment Preview
Create a person class containing the following state and behavior as identified below. In addition, the program should implement a getOldestPerson () method that returns the full name of the oldest person. You must also create a personTest class to store atleast five person and return the older person from the list Solution package new2; public class Person { private String Firstname; private String Lastname; private String Gender; private int Age; public Person(String Firstname, String Lastname, String Gender, int Age) { this.Firstname = Firstname; this.Lastname = Lastname; this.Gender = Gender; this.Age = Age; } 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 String getGender() { return Gender; } public void setGender(String Gender) { this.Gender = Gender; } public int getAge() { return Age; } public void setAge(int Age) { this.Age = Age; } public String getOldestPerson(Person p[]) { int max = 0; for (int i = 0; i < p.length - 1; i++) { if (p[i].Age > p[i + 1].Age) { max = ...
Purchase document to see full attachment
User generated content is uploaded by users for the purposes of learning and should be used following Studypool's honor code & terms of service.
Studypool
4.7
Indeed
4.5
Sitejabber
4.4

Similar Documents